Sha256: aa97a8934bce84bd279e20fc3aba60b84e583e7091bbb357e0a2e01aba6f2eb4

Contents?: true

Size: 1.42 KB

Versions: 49

Compression:

Stored size: 1.42 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

    # TODO: Test that before_create tasks are not run on a new Stack.
    describe 'before 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
          before_create_task scope.task
        end
      end

      it 'is registered before Stack#apply is called' do
        expect(subject.tasks[:before_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[:before_create]).to be_empty
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
convection-1.1.3 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.1.2 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.1.1 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.1.0 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.0.7 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.0.6 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.0.5 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.0.4 spec/convection/control/stack/before_create_tasks_spec.rb
convection-1.0.3 spec/convection/control/stack/before_create_tasks_spec.rb