Sha256: fc7f7021252df3ef5732d5c4d9c0b11aaf6fdbb853ae3c01e12ff3e2fa80bc43

Contents?: true

Size: 1.35 KB

Versions: 49

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

module Convection::Control
  describe Stack do
    let(:template) do
      Convection.template do
        description 'EC2 VPC Test Template'

        ec2_vpc 'TargetVPC' do
          network '10.0.0.0'
          subnet_length 24
          enable_dns
        end
      end
    end

    describe 'after create tasks' do
      include_context 'with a CollectAvailabilityZonesTask defined'
      include_context 'with a mock CloudFormation client'
      include_context 'with a mock EC2 client'

      before do
        allow(Aws::CloudFormation::Client).to receive(:new).and_return(cf_client)
        allow(Aws::EC2::Client).to receive(:new).and_return(ec2_client)
      end
      let(:task) { CollectAvailabilityZonesTask.new }
      subject do
        scope = self
        Convection::Control::Stack.new('EC2 VPC Test Stack', template) do
          after_create_task scope.task
        end
      end

      it 'is registered after Stack#apply is called' do
        expect(subject.tasks[:after_create]).to_not be_empty
      end

      it 'is executed on Stack#apply' do
        subject.apply

        expect(task.availability_zones).to include(a_string_starting_with('eu-central-1'))
      end

      it 'is deregistered after Stack#apply is called' do
        subject.apply

        expect(subject.tasks[:after_create]).to be_empty
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
convection-2.3.1 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.3.0 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.29 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.28.pre.beta.2 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.28.pre.beta.1 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.27 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.26 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.25 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.24 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.23 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.22 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.21 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.20 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.19 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.18 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.17 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.16 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.15 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.14 spec/convection/control/stack/after_create_tasks_spec.rb
convection-2.2.13 spec/convection/control/stack/after_create_tasks_spec.rb