automan 2.3.5 → 2.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -5
  3. data/automan.gemspec +3 -3
  4. data/lib/automan.rb +0 -1
  5. data/lib/automan/base.rb +3 -7
  6. data/lib/automan/beanstalk/deployer.rb +1 -1
  7. data/lib/automan/beanstalk/package.rb +1 -1
  8. data/lib/automan/beanstalk/router.rb +1 -1
  9. data/lib/automan/cli/snapper.rb +23 -3
  10. data/lib/automan/cli/stacker.rb +0 -19
  11. data/lib/automan/cloudformation/launcher.rb +3 -6
  12. data/lib/automan/cloudformation/replacer.rb +1 -1
  13. data/lib/automan/cloudformation/terminator.rb +1 -1
  14. data/lib/automan/ec2/image.rb +3 -3
  15. data/lib/automan/mixins/aws_caller.rb +7 -21
  16. data/lib/automan/rds/snapshot.rb +25 -35
  17. data/lib/automan/s3/downloader.rb +1 -10
  18. data/lib/automan/version.rb +1 -1
  19. data/spec/beanstalk/application_spec.rb +17 -17
  20. data/spec/beanstalk/configuration_spec.rb +24 -24
  21. data/spec/beanstalk/deployer_spec.rb +65 -65
  22. data/spec/beanstalk/router_spec.rb +19 -18
  23. data/spec/beanstalk/terminator_spec.rb +16 -16
  24. data/spec/beanstalk/uploader_spec.rb +13 -13
  25. data/spec/beanstalk/version_spec.rb +10 -8
  26. data/spec/cloudformation/launcher_spec.rb +65 -63
  27. data/spec/cloudformation/replacer_spec.rb +10 -10
  28. data/spec/cloudformation/terminator_spec.rb +23 -23
  29. data/spec/cloudformation/uploader_spec.rb +13 -13
  30. data/spec/ec2/image_spec.rb +55 -55
  31. data/spec/ec2/instance_spec.rb +17 -17
  32. data/spec/mixins/aws_caller_spec.rb +9 -9
  33. data/spec/mixins/utils_spec.rb +28 -27
  34. data/spec/rds/snapshot_spec.rb +46 -44
  35. metadata +9 -22
  36. data/.ruby-gemset +0 -1
  37. data/.ruby-version +0 -1
  38. data/.travis.yml +0 -5
  39. data/lib/automan/elasticache/router.rb +0 -79
  40. data/spec/elasticache/router_spec.rb +0 -29
  41. data/templates/stacker/.env.example +0 -14
  42. data/templates/stacker/.gitignore +0 -2
  43. data/templates/stacker/.ruby-gemset.tt +0 -1
  44. data/templates/stacker/.ruby-version +0 -1
  45. data/templates/stacker/Gemfile +0 -4
  46. data/templates/stacker/bin/%app_name%.tt +0 -62
  47. data/templates/stacker/bin/launch_%app_name%.sh.tt +0 -12
@@ -6,7 +6,7 @@ describe Automan::Beanstalk::Uploader do
6
6
  u = Automan::Beanstalk::Uploader.new
7
7
  u.logger = Logger.new('/dev/null')
8
8
  u.template_files = 'foo'
9
- allow(u).to receive(:config_templates).and_return(['foo'])
9
+ u.stub(:config_templates).and_return(['foo'])
10
10
  u
11
11
  end
12
12
 
@@ -18,36 +18,36 @@ describe Automan::Beanstalk::Uploader do
18
18
  describe '#config_templates_valid?' do
19
19
 
20
20
  it 'raises error if config templates do not exist' do
21
- allow(subject).to receive(:config_templates).and_return([])
21
+ u.stub(:config_templates).and_return([])
22
22
  expect {
23
- subject.config_templates_valid?
23
+ u.config_templates_valid?
24
24
  }.to raise_error(Automan::Beanstalk::NoConfigurationTemplatesError)
25
25
  end
26
26
 
27
27
  it 'returns true if config templates are valid json' do
28
- allow(subject).to receive(:read_config_template).and_return('[{}]')
29
- expect(subject.config_templates_valid?).to be_truthy
28
+ u.stub(:read_config_template).and_return('[{}]')
29
+ u.config_templates_valid?.should be_true
30
30
  end
31
31
 
32
32
  it 'returns false if config templates are invalid json' do
33
- allow(subject).to receive(:read_config_template).and_return('@#$%#')
34
- expect(subject.config_templates_valid?).to be_falsey
33
+ u.stub(:read_config_template).and_return('@#$%#')
34
+ u.config_templates_valid?.should be_false
35
35
  end
36
36
  end
37
37
 
38
38
  describe '#upload_config_templates' do
39
39
  it 'raises error if any config template fails validation' do
40
- allow(subject).to receive(:config_templates_valid?).and_return(false)
40
+ u.stub(:config_templates_valid?).and_return(false)
41
41
  expect {
42
- subject.upload_config_templates
42
+ u.upload_config_templates
43
43
  }.to raise_error(Automan::Beanstalk::InvalidConfigurationTemplateError)
44
44
  end
45
45
 
46
46
  it 'uploads files if they are valid' do
47
- allow(subject).to receive(:config_templates).and_return(%w[a b c])
48
- allow(subject).to receive(:config_templates_valid?).and_return(true)
49
- expect(subject).to receive(:upload_file).exactly(3).times
50
- subject.upload_config_templates
47
+ u.stub(:config_templates).and_return(%w[a b c])
48
+ u.stub(:config_templates_valid?).and_return(true)
49
+ u.should_receive(:upload_file).exactly(3).times
50
+ u.upload_config_templates
51
51
  end
52
52
  end
53
53
  end
@@ -16,24 +16,25 @@ describe Automan::Beanstalk::Version do
16
16
  v.eb = AWS::ElasticBeanstalk::Client.new
17
17
  v.application = 'foo'
18
18
  v.label = 'v4'
19
+ v.log_aws_calls = false
19
20
  v.logger = Logger.new('/dev/null')
20
21
  v
21
22
  end
22
23
 
23
24
  it "is true when version exists in response" do
24
- resp = subject.eb.stub_for :describe_application_versions
25
+ resp = v.eb.stub_for :describe_application_versions
25
26
  resp.data[:application_versions] = [
26
- {application_name: subject.application, version_label: subject.label}
27
+ {application_name: v.application, version_label: v.label}
27
28
  ]
28
- expect(subject.exists?).to be_truthy
29
+ v.exists?.should be_true
29
30
  end
30
31
 
31
32
  it "is false when version is not in response" do
32
- resp = subject.eb.stub_for :describe_application_versions
33
+ resp = v.eb.stub_for :describe_application_versions
33
34
  resp.data[:application_versions] = [
34
35
  {application_name: '', version_label: ''}
35
36
  ]
36
- expect(subject.exists?).to be_falsey
37
+ v.exists?.should be_false
37
38
  end
38
39
  end
39
40
 
@@ -46,10 +47,11 @@ describe Automan::Beanstalk::Version do
46
47
  end
47
48
 
48
49
  it 'ignores AWS::ElasticBeanstalk::Errors::SourceBundleDeletionFailure' do
49
- subject.eb = double()
50
- allow(subject.eb).to receive(:delete_application_version).and_raise(AWS::ElasticBeanstalk::Errors::SourceBundleDeletionFailure)
50
+ eb = double(:eb)
51
+ eb.stub(:delete_application_version).and_raise(AWS::ElasticBeanstalk::Errors::SourceBundleDeletionFailure)
52
+ v.eb = eb
51
53
  expect {
52
- subject.delete_by_label('foo')
54
+ v.delete_by_label('foo')
53
55
  }.not_to raise_error
54
56
  end
55
57
 
@@ -17,29 +17,30 @@ describe Automan::Cloudformation::Launcher do
17
17
  it { should respond_to :stack_update_complete? }
18
18
 
19
19
  describe '#read_manifest' do
20
- subject() do
20
+ subject(:s) do
21
21
  AWS.stub!
22
- Automan::Cloudformation::Launcher.new
22
+ s = Automan::Cloudformation::Launcher.new
23
+ s
23
24
  end
24
25
 
25
26
  it 'raises MissingManifestError if manifest does not exist' do
26
- allow(subject).to receive(:manifest_exists?).and_return(false)
27
+ s.stub(:manifest_exists?).and_return(false)
27
28
  expect {
28
- subject.read_manifest
29
+ s.read_manifest
29
30
  }.to raise_error(Automan::Cloudformation::MissingManifestError)
30
31
  end
31
32
 
32
33
  it 'merges manifest contents into parameters hash' do
33
- allow(subject).to receive(:manifest_exists?).and_return(true)
34
- allow(subject).to receive(:s3_read).and_return('{"foo": "bar", "big": "poppa"}')
35
- subject.parameters = {'foo'=> 'baz', 'fo'=> 'shizzle'}
36
- subject.read_manifest
37
- expect(subject.parameters).to eq({'foo' => 'bar', 'fo' => 'shizzle', 'big' => 'poppa'})
34
+ s.stub(:manifest_exists?).and_return(true)
35
+ s.stub(:s3_read).and_return('{"foo": "bar", "big": "poppa"}')
36
+ s.parameters = {'foo'=> 'baz', 'fo'=> 'shizzle'}
37
+ s.read_manifest
38
+ s.parameters.should eq({'foo' => 'bar', 'fo' => 'shizzle', 'big' => 'poppa'})
38
39
  end
39
40
  end
40
41
 
41
42
  describe '#parse_template_parameters' do
42
- subject() do
43
+ subject(:s) do
43
44
  AWS.stub!
44
45
  s = Automan::Cloudformation::Launcher.new
45
46
  s.cfn = AWS::CloudFormation.new
@@ -48,30 +49,31 @@ describe Automan::Cloudformation::Launcher do
48
49
  end
49
50
 
50
51
  it "returns a hash" do
51
- subject.template = File.join(File.dirname(__FILE__), 'templates', 'worker_role.json')
52
- result = subject.parse_template_parameters
53
- expect(result.class).to eq(Hash)
52
+ s.template = File.join(File.dirname(__FILE__), 'templates', 'worker_role.json')
53
+ result = s.parse_template_parameters
54
+ result.class.should eq(Hash)
54
55
  end
55
56
 
56
57
  end
57
58
 
58
59
  describe '#template_handle' do
59
- subject() do
60
+ subject(:s) do
60
61
  AWS.stub!
61
- Automan::Cloudformation::Launcher.new
62
+ s = Automan::Cloudformation::Launcher.new
63
+ s
62
64
  end
63
65
 
64
66
  it "returns an s3 key if it is an s3 path" do
65
- expect(subject.template_handle("s3://foo/bar/baz")).to be_a AWS::S3::S3Object
67
+ s.template_handle("s3://foo/bar/baz").should be_a AWS::S3::S3Object
66
68
  end
67
69
 
68
70
  it "returns a string if it is a local file" do
69
- expect(subject.template_handle(__FILE__)).to be_a String
71
+ s.template_handle(__FILE__).should be_a String
70
72
  end
71
73
  end
72
74
 
73
75
  describe '#validate_parameters' do
74
- subject() do
76
+ subject(:s) do
75
77
  AWS.stub!
76
78
  s = Automan::Cloudformation::Launcher.new
77
79
  s.logger = Logger.new('/dev/null')
@@ -80,99 +82,99 @@ describe Automan::Cloudformation::Launcher do
80
82
  end
81
83
 
82
84
  it "raises error if no parameters were specified" do
83
- subject.parameters = nil
85
+ s.parameters = nil
84
86
  expect {
85
- subject.validate_parameters
87
+ s.validate_parameters
86
88
  }.to raise_error Automan::Cloudformation::MissingParametersError
87
89
  end
88
90
 
89
91
  it "raises error if the template doesn't validate" do
90
- allow(subject).to receive(:parse_template_parameters).and_return({code: 'foo', message: 'bar'})
92
+ Automan::Cloudformation::Launcher.any_instance.stub(:parse_template_parameters).and_return({code: 'foo', message: 'bar'})
91
93
  expect {
92
- subject.validate_parameters
94
+ s.validate_parameters
93
95
  }.to raise_error Automan::Cloudformation::BadTemplateError
94
96
  end
95
97
 
96
98
  it "raises error if a required parameter isn't present" do
97
- allow(subject).to receive(:parse_template_parameters).and_return(parameters: [{parameter_key: 'foo'}])
99
+ Automan::Cloudformation::Launcher.any_instance.stub(:parse_template_parameters).and_return(parameters: [{parameter_key: 'foo'}])
98
100
  expect {
99
- subject.validate_parameters
101
+ s.validate_parameters
100
102
  }.to raise_error Automan::Cloudformation::MissingParametersError
101
103
  end
102
104
 
103
105
  it "raises no error if all required parameters are present" do
104
- allow(subject).to receive(:parse_template_parameters).and_return(parameters: [{parameter_key: 'foo'}])
105
- subject.parameters = {'foo' => 'bar'}
106
+ Automan::Cloudformation::Launcher.any_instance.stub(:parse_template_parameters).and_return(parameters: [{parameter_key: 'foo'}])
107
+ s.parameters = {'foo' => 'bar'}
106
108
  expect {
107
- subject.validate_parameters
109
+ s.validate_parameters
108
110
  }.not_to raise_error
109
111
  end
110
112
 
111
113
  it "raises no error if there are no required parameters" do
112
- allow(subject).to receive(:parse_template_parameters).and_return(parameters: [{parameter_key: 'foo', default_value: 'bar'}])
114
+ Automan::Cloudformation::Launcher.any_instance.stub(:parse_template_parameters).and_return(parameters: [{parameter_key: 'foo', default_value: 'bar'}])
113
115
  expect {
114
- subject.validate_parameters
116
+ s.validate_parameters
115
117
  }.not_to raise_error
116
118
  end
117
119
  end
118
120
 
119
121
  describe '#update' do
120
- subject() do
122
+ subject(:s) do
121
123
  AWS.stub!
122
124
  s = Automan::Cloudformation::Launcher.new
123
125
  s.logger = Logger.new('/dev/null')
124
- allow(s).to receive(:template_handle).and_return('foo')
126
+ s.stub(:template_handle).and_return('foo')
125
127
  s
126
128
  end
127
129
 
128
130
  it "ignores AWS::CloudFormation::Errors::ValidationError when no updates are to be performed" do
129
- allow(subject).to receive(:update_stack).and_raise AWS::CloudFormation::Errors::ValidationError.new("No updates are to be performed.")
131
+ s.stub(:update_stack).and_raise AWS::CloudFormation::Errors::ValidationError.new("No updates are to be performed.")
130
132
  expect {
131
- subject.update
133
+ s.update
132
134
  }.to_not raise_error
133
135
  end
134
136
 
135
137
  it 're-raises any other ValidationError' do
136
- allow(subject).to receive(:update_stack).and_raise AWS::CloudFormation::Errors::ValidationError.new("foo")
138
+ s.stub(:update_stack).and_raise AWS::CloudFormation::Errors::ValidationError.new("foo")
137
139
  expect {
138
- subject.update
140
+ s.update
139
141
  }.to raise_error AWS::CloudFormation::Errors::ValidationError
140
142
  end
141
143
  end
142
144
 
143
145
  describe '#launch_or_update' do
144
- subject() do
146
+ subject(:s) do
145
147
  AWS.stub!
146
148
  s = Automan::Cloudformation::Launcher.new
147
149
  s.logger = Logger.new('/dev/null')
148
- allow(s).to receive(:validate_parameters)
150
+ s.stub(:validate_parameters)
149
151
  s
150
152
  end
151
153
 
152
154
  it "launches a new stack if it does not exist" do
153
- allow(subject).to receive(:stack_exists?).and_return(false)
154
- expect(subject).to receive(:launch)
155
- subject.launch_or_update
155
+ s.stub(:stack_exists?).and_return(false)
156
+ s.should_receive(:launch)
157
+ s.launch_or_update
156
158
  end
157
159
 
158
160
  it "updates an existing stack if update is enabled" do
159
- allow(subject).to receive(:stack_exists?).and_return(true)
160
- allow(subject).to receive(:enable_update).and_return(true)
161
- expect(subject).to receive(:update)
162
- subject.launch_or_update
161
+ s.stub(:stack_exists?).and_return(true)
162
+ s.stub(:enable_update).and_return(true)
163
+ s.should_receive(:update)
164
+ s.launch_or_update
163
165
  end
164
166
 
165
167
  it "raises an error when updating an existing stack w/o update enabled" do
166
- allow(subject).to receive(:stack_exists?).and_return(true)
167
- allow(subject).to receive(:enable_update).and_return(false)
168
+ s.stub(:stack_exists?).and_return(true)
169
+ s.stub(:enable_update).and_return(false)
168
170
  expect {
169
- subject.launch_or_update
171
+ s.launch_or_update
170
172
  }.to raise_error Automan::Cloudformation::StackExistsError
171
173
  end
172
174
  end
173
175
 
174
176
  describe '#stack_launch_complete?' do
175
- subject() do
177
+ subject(:s) do
176
178
  AWS.stub!
177
179
  s = Automan::Cloudformation::Launcher.new
178
180
  s.logger = Logger.new('/dev/null')
@@ -180,35 +182,35 @@ describe Automan::Cloudformation::Launcher do
180
182
  end
181
183
 
182
184
  it 'returns true when the stack completes' do
183
- allow(subject).to receive(:stack_status).and_return('CREATE_COMPLETE')
184
- expect(subject.stack_launch_complete?).to be_truthy
185
+ s.stub(:stack_status).and_return('CREATE_COMPLETE')
186
+ s.stack_launch_complete?.should be_true
185
187
  end
186
188
 
187
189
  it 'raises an error when the stack fails' do
188
- allow(subject).to receive(:stack_status).and_return('CREATE_FAILED')
190
+ s.stub(:stack_status).and_return('CREATE_FAILED')
189
191
  expect {
190
- subject.stack_launch_complete?
192
+ s.stack_launch_complete?
191
193
  }.to raise_error Automan::Cloudformation::StackCreationError
192
194
  end
193
195
 
194
196
  rollback_states = %w[ROLLBACK_COMPLETE ROLLBACK_FAILED ROLLBACK_IN_PROGRESS]
195
197
  rollback_states.each do |state|
196
198
  it "raises an error when the stack goes into #{state} state" do
197
- allow(subject).to receive(:stack_status).and_return(state)
199
+ s.stub(:stack_status).and_return(state)
198
200
  expect {
199
- subject.stack_launch_complete?
201
+ s.stack_launch_complete?
200
202
  }.to raise_error Automan::Cloudformation::StackCreationError
201
203
  end
202
204
  end
203
205
 
204
206
  it 'returns false for any other state' do
205
- allow(subject).to receive(:stack_status).and_return('foo')
206
- expect(subject.stack_launch_complete?).to be_falsey
207
+ s.stub(:stack_status).and_return('foo')
208
+ s.stack_launch_complete?.should be_false
207
209
  end
208
210
  end
209
211
 
210
212
  describe '#stack_update_complete?' do
211
- subject() do
213
+ subject(:s) do
212
214
  AWS.stub!
213
215
  s = Automan::Cloudformation::Launcher.new
214
216
  s.logger = Logger.new('/dev/null')
@@ -216,23 +218,23 @@ describe Automan::Cloudformation::Launcher do
216
218
  end
217
219
 
218
220
  it 'returns true when the stack completes' do
219
- allow(subject).to receive(:stack_status).and_return('UPDATE_COMPLETE')
220
- expect(subject.stack_update_complete?).to be_truthy
221
+ s.stub(:stack_status).and_return('UPDATE_COMPLETE')
222
+ s.stack_update_complete?.should be_true
221
223
  end
222
224
 
223
225
  rollback_states = %w[UPDATE_ROLLBACK_COMPLETE UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_IN_PROGRESS]
224
226
  rollback_states.each do |state|
225
227
  it "raises an error when the stack enters #{state} state" do
226
- allow(subject).to receive(:stack_status).and_return(state)
228
+ s.stub(:stack_status).and_return(state)
227
229
  expect {
228
- subject.stack_update_complete?
230
+ s.stack_update_complete?
229
231
  }.to raise_error Automan::Cloudformation::StackUpdateError
230
232
  end
231
233
  end
232
234
 
233
235
  it 'returns false for any other state' do
234
- allow(subject).to receive(:stack_status).and_return('foo')
235
- expect(subject.stack_update_complete?).to be_falsey
236
+ s.stub(:stack_status).and_return('foo')
237
+ s.stack_update_complete?.should be_false
236
238
  end
237
239
  end
238
240
  end
@@ -1,15 +1,15 @@
1
1
  require 'automan'
2
2
 
3
3
  describe Automan::Cloudformation::Replacer do
4
- it { is_expected.to respond_to :name }
5
- it { is_expected.to respond_to :replace_instances }
6
- it { is_expected.to respond_to :ok_to_replace_instances? }
7
- it { is_expected.to respond_to :stack_exists? }
4
+ it { should respond_to :name }
5
+ it { should respond_to :replace_instances }
6
+ it { should respond_to :ok_to_replace_instances? }
7
+ it { should respond_to :stack_exists? }
8
8
 
9
9
  describe '#ok_to_replace_instances?' do
10
- subject() do
10
+ subject(:r) do
11
11
  AWS.stub!
12
- Automan::Cloudformation::Replacer.new
12
+ r = Automan::Cloudformation::Replacer.new
13
13
  end
14
14
 
15
15
  good_states = %w[UPDATE_COMPLETE]
@@ -30,28 +30,28 @@ describe Automan::Cloudformation::Replacer do
30
30
 
31
31
  good_states.each do |state|
32
32
  it "returns true when stack is in the right state (state: #{state})" do
33
- expect(subject.ok_to_replace_instances?(state, Time.now)).to be_truthy
33
+ r.ok_to_replace_instances?(state, Time.now).should be_true
34
34
  end
35
35
  end
36
36
 
37
37
  good_states.each do |state|
38
38
  it "returns false when stack is in the right state but has not been updated in the last 5m" do
39
39
  last_updated = Time.now - (5 * 60 + 1)
40
- expect(subject.ok_to_replace_instances?(state, last_updated)).to be_falsey
40
+ r.ok_to_replace_instances?(state, last_updated).should be_false
41
41
  end
42
42
  end
43
43
 
44
44
  bad_states.each do |state|
45
45
  it "raises error when stack is borked (state: #{state})" do
46
46
  expect {
47
- subject.ok_to_replace_instances?(state, Time.now)
47
+ r.ok_to_replace_instances?(state, Time.now)
48
48
  }.to raise_error Automan::Cloudformation::StackBrokenError
49
49
  end
50
50
  end
51
51
 
52
52
  wait_states.each do |state|
53
53
  it "returns false when it is not yet ok to replace (state: #{state})" do
54
- expect(subject.ok_to_replace_instances?(state, Time.now)).to be_falsey
54
+ r.ok_to_replace_instances?(state, Time.now).should be_false
55
55
  end
56
56
  end
57
57
  end
@@ -1,15 +1,15 @@
1
1
  require 'automan'
2
2
 
3
3
  describe Automan::Cloudformation::Terminator do
4
- it { is_expected.to respond_to :name }
5
- it { is_expected.to respond_to :terminate }
6
- it { is_expected.to respond_to :stack_exists? }
7
- it { is_expected.to respond_to :stack_deleted? }
8
- it { is_expected.to respond_to :delete_stack }
9
- it { is_expected.to respond_to :wait_for_completion }
4
+ it { should respond_to :name }
5
+ it { should respond_to :terminate }
6
+ it { should respond_to :stack_exists? }
7
+ it { should respond_to :stack_deleted? }
8
+ it { should respond_to :delete_stack }
9
+ it { should respond_to :wait_for_completion }
10
10
 
11
11
  describe '#terminate' do
12
- subject() do
12
+ subject(:t) do
13
13
  AWS.stub!
14
14
  t = Automan::Cloudformation::Terminator.new
15
15
  t.logger = Logger.new('/dev/null')
@@ -17,20 +17,20 @@ describe Automan::Cloudformation::Terminator do
17
17
  end
18
18
 
19
19
  it 'should call #delete_stack if the stack exists' do
20
- allow(subject).to receive(:stack_exists?).and_return(true)
21
- expect(subject).to receive :delete_stack
22
- subject.terminate
20
+ t.stub(:stack_exists?).and_return(true)
21
+ t.should_receive :delete_stack
22
+ t.terminate
23
23
  end
24
24
 
25
25
  it 'should not call #delete_stack if the stack does not exist' do
26
- allow(subject).to receive(:stack_exists?).and_return(false)
27
- expect(subject).to_not receive :delete_stack
28
- subject.terminate
26
+ t.stub(:stack_exists?).and_return(false)
27
+ t.should_not_receive :delete_stack
28
+ t.terminate
29
29
  end
30
30
  end
31
31
 
32
32
  describe '#stack_deleted?' do
33
- subject() do
33
+ subject(:t) do
34
34
  AWS.stub!
35
35
  t = Automan::Cloudformation::Terminator.new
36
36
  t.logger = Logger.new('/dev/null')
@@ -38,26 +38,26 @@ describe Automan::Cloudformation::Terminator do
38
38
  end
39
39
 
40
40
  it 'returns true if the stack does not exist' do
41
- allow(subject).to receive(:stack_exists?).and_return(false)
42
- allow(subject).to receive(:stack_status).and_raise StandardError
43
- expect(subject.stack_deleted?('foo')).to be_truthy
41
+ t.stub(:stack_exists?).and_return(false)
42
+ t.stub(:stack_status).and_raise StandardError
43
+ t.stack_deleted?('foo').should be_true
44
44
  end
45
45
 
46
46
  it 'returns true when status is DELETE_COMPLETE' do
47
- allow(subject).to receive(:stack_status).and_return('DELETE_COMPLETE')
48
- expect(subject.stack_deleted?('foo')).to be_truthy
47
+ t.stub(:stack_status).and_return('DELETE_COMPLETE')
48
+ t.stack_deleted?('foo').should be_true
49
49
  end
50
50
 
51
51
  it 'raises an error when the delete fails' do
52
- allow(subject).to receive(:stack_status).and_return('DELETE_FAILED')
52
+ t.stub(:stack_status).and_return('DELETE_FAILED')
53
53
  expect {
54
- subject.stack_deleted?('foo')
54
+ t.stack_deleted?('foo')
55
55
  }.to raise_error Automan::Cloudformation::StackDeletionError
56
56
  end
57
57
 
58
58
  it 'returns false for any other status' do
59
- allow(subject).to receive(:stack_status).and_return('foo')
60
- expect(subject.stack_deleted?('foo')).to be_falsey
59
+ t.stub(:stack_status).and_return('foo')
60
+ t.stack_deleted?('foo').should be_false
61
61
  end
62
62
  end
63
63
  end