Sha256: c57ae9fa1dde1f8479a02dbb8d0021ba166671dd8258345cb35f9e0bdd26d85e

Contents?: true

Size: 1.76 KB

Versions: 62

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

class Convection::Model::Template::Resource
  describe Lambda do
    let(:template) do
      Convection.template do
        description 'Conditions Test Template'

        lambda_function 'TestLambda' do
          description 'Test description'
          handler 'index.handler'
          runtime 'nodejs'
          role 'arn:aws:x:y:z'

          code do
            s3_bucket 'testbucket'
            s3_key 'testkey'
          end

          vpc_config do
            security_groups %w(group1 group2)
            subnets %w(subnet1a subnet1b)
          end
        end
      end
    end

    subject do
      template_json
        .fetch('Resources')
        .fetch('TestLambda')
        .fetch('Properties')
    end

    it 's3 bucket configurations match what is defined in the template' do
      expect(subject['Code']['S3Bucket']).to eq('testbucket')
      expect(subject['Code']['S3Key']).to eq('testkey')
    end

    it 'the role matches the value defined in the template' do
      expect(subject['Role']).to eq('arn:aws:x:y:z')
    end

    it 'vpc config parameters match the values defined in the template' do
      expect(subject['VpcConfig']).to_not eq(nil)
    end

    it 'security group ids are stored in an array' do
      expect(subject['VpcConfig']['SecurityGroupIds']).to be_a(Array)
    end

    it 'security groups is an array of 2 group ids' do
      expect(subject['VpcConfig']['SecurityGroupIds'].size).to eq(2)
    end

    it 'subnet ids are stored in an array' do
      expect(subject['VpcConfig']['SubnetIds']).to be_a(Array)
    end

    it 'SubnetIds is an array of 2 group ids' do
      expect(subject['VpcConfig']['SubnetIds'].size).to eq(2)
    end

    private

    def template_json
      JSON.parse(template.to_json)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
convection-2.2.26 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.25 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.24 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.23 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.22 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.21 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.20 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.19 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.18 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.17 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.16 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.15 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.14 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.13 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.12 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.11 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.10 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.9 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.8 spec/convection/model/template/resource/lambdas_spec.rb
convection-2.2.7 spec/convection/model/template/resource/lambdas_spec.rb