Sha256: fde7ae30ba15282de99f3e4e0d8cad0a35abe665bb4f8804fe65ad725368e173

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Awspec::Generator
  module Spec
    class Alb
      include Awspec::Helper::Finder
      def generate_by_vpc_id(vpc_id)
        describes = %w[
          load_balancer_name
        ]
        vpc = find_vpc(vpc_id)
        raise 'Not Found VPC' unless vpc

        @vpc_id = vpc[:vpc_id]
        @vpc_tag_name = vpc.tag_name
        albs = select_alb_by_vpc_id(@vpc_id)

        specs = albs.map do |alb|
          content = ERB.new(alb_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
        end
        specs.join("\n")
      end

      def alb_spec_template
        <<-'EOF'
describe alb('<%= alb.load_balancer_name %>') do
  it { should exist }
  its(:load_balancer_arn) { should eq '<%= alb.load_balancer_arn %>' }
  its(:dns_name) { should eq '<%= alb.dns_name %>' }
  its(:load_balancer_name) { should eq '<%= alb.load_balancer_name %>' }
  its(:scheme) { should eq '<%= alb.scheme %>' }
  its(:vpc_id) { should eq '<%= alb.vpc_id %>' }
  its(:type) { should eq '<%= alb.type %>' }
  its(:ip_address_type) { should eq '<%= alb.ip_address_type %>' }
end
EOF
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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