Sha256: 983547a12fddc450f2ea7c62e78db5752e63367869edcc0cc544bca055089550

Contents?: true

Size: 1.1 KB

Versions: 181

Compression:

Stored size: 1.1 KB

Contents

module Awspec::Generator
  module Spec
    class NatGateway
      include Awspec::Helper::Finder
      def generate_by_vpc_id(vpc_id)
        describes = %w(
        )
        vpc = find_vpc(vpc_id)
        raise 'Not Found VPC' unless vpc
        @vpc_id = vpc[:vpc_id]
        @vpc_tag_name = vpc.tag_name
        nat_gateways = select_nat_gateway_by_vpc_id(@vpc_id)
        specs = nat_gateways.map do |nat_gateway|
          nat_gateway_id = nat_gateway[:nat_gateway_id]
          content = ERB.new(nat_gateway_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
        end
        specs.join("\n")
      end

      def nat_gateway_spec_template
        template = <<-'EOF'
describe nat_gateway('<%= nat_gateway_id %>') do
  it { should exist }
  it { should be_<%= nat_gateway.state %> }
<%- if @vpc_tag_name -%>
  it { should belong_to_vpc('<%= @vpc_tag_name %>') }
<%- else -%>
  it { should belong_to_vpc('<%= @vpc_id %>') }
<%- end -%>
<% nat_gateway.nat_gateway_addresses.each do |address| %>
  it { should have_eip('<%= address.public_ip %>') }
<% end %>
end
EOF
        template
      end
    end
  end
end

Version data entries

181 entries across 181 versions & 4 rubygems

Version Path
awspec-1.6.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.5.4 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.5.3 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.5.2 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.5.1 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.5.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.4.3 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.4.2 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.4.1 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.4.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.3.1 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.3.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.2.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.1.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.0.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.0.0.rc lib/awspec/generator/spec/nat_gateway.rb
awspec-0.88.2 lib/awspec/generator/spec/nat_gateway.rb
awspec-0.88.1 lib/awspec/generator/spec/nat_gateway.rb
awspec-0.88.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-0.87.1 lib/awspec/generator/spec/nat_gateway.rb