kongou-ae
8/3/2015 - 1:20 PM

log

log

$ more spec/localhost/vpc_spec.rb 
require 'spec_helper'

  subnet_1a_cidr = "10.0.0.0/18"
  subnet_1a_id   = "subnet-1d8b206a"
  subnet_1c_cidr = "10.0.64.0/18"
  subnet_1c_id   = "subnet-35e02d6c"
  vpc_cidr       = "10.0.0.0/16"
  vpc_id         = "vpc-6eb2690b"

describe 'the example network' do

  describe vpc_resource(vpc_id) do
    it { should be_available }
    it { should be_attached_to_a_internet_gateway }
    its(:cidr_block) { should eq vpc_cidr }
    its(:subnets) { should eq [ subnet_1c_cidr, subnet_1a_cidr ].sort }
  end

  describe subnet_resource(subnet_1a_id) do
    it { should be_available }
    its(:vpc_id) { should eq vpc_id}
    its(:cidr_block){ should eq subnet_1a_cidr }
    its(:availability_zone) { should eq "ap-northeast-1a"}
  end

  describe subnet_resource(subnet_1c_id) do
    it { should be_available }
    its(:vpc_id) { should eq vpc_id}
    its(:cidr_block){ should eq subnet_1c_cidr }
    its(:availability_zone) { should eq "ap-northeast-1c"}
  end

end
$ rbenv exec bundle exec rake spec                   
/home/aimless/.rbenv/versions/2.1.1/bin/ruby -I/home/aimless/study/serverspec/vpc/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.2.3/lib:/home/aimless/study/serverspec/vpc/vendor/bundle/ruby/2.1.0/gems/rspec-support-3.2.2/lib /home/aimless/study/serverspec/vpc/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.2.3/exe/rspec --pattern spec/localhost/\*_spec.rb

the example network
  VPC: vpc-6eb2690b
    should be available
    should be attached to a internet gateway
    cidr_block
      should eq "10.0.0.0/16"
    subnets
      should eq ["10.0.0.0/18", "10.0.64.0/18"]
  SUBNET: subnet-1d8b206a
    should be available
    vpc_id
      should eq "vpc-6eb2690b"
    cidr_block
      should eq "10.0.0.0/18"
    availability_zone
      should eq "ap-northeast-1a"
  SUBNET: subnet-35e02d6c
    should be available
    vpc_id
      should eq "vpc-6eb2690b"
    cidr_block
      should eq "10.0.64.0/18"
    availability_zone
      should eq "ap-northeast-1c"

Finished in 1.44 seconds (files took 0.48419 seconds to load)
12 examples, 0 failures