Sha256: a01eb3f86afec45bf70ab640bc29bfa5a1a08c43e5ca9c4b3cab30c14b0b79cb

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

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
        <<-'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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
awspec-1.30.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.29.3 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.29.2 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.29.1 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.29.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.28.2 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.28.1 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.28.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.27.1 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.27.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.26.0 lib/awspec/generator/spec/nat_gateway.rb
awspec-1.25.2 lib/awspec/generator/spec/nat_gateway.rb