diff --git a/spec/lib/cloud_formation/executor_spec.rb b/spec/lib/cloud_formation/executor_spec.rb index 20d94dee..d59b59a9 100644 --- a/spec/lib/cloud_formation/executor_spec.rb +++ b/spec/lib/cloud_formation/executor_spec.rb @@ -38,11 +38,22 @@ end describe '#create_or_update' do - it 'raises an error if the stack was rolled back' do - allow(executor).to receive(:stack_status) { 'ROLLBACK_COMPLETE' } - expect { executor.create_or_update }.to raise_error CloudFormation::CannotUpdateRolledbackStackException + it 'deletes the stack if it was rolled back' do + status = 'ROLLBACK_COMPLETE' + allow(executor).to receive(:stack_status) { status } + + expect(client).to receive(:delete_stack).with({stack_name: "test"}) { + status = 'DELETE_COMPLETE' + }.once + + expect(executor).to receive(:create) + + + executor.create_or_update end + + it 'raises an error if the stack is still being updated' do allow(executor).to receive(:stack_status) { 'UPDATE_IN_PROGRESS' } expect { executor.create_or_update }.to raise_error CloudFormation::UpdateInProgressException