aerosol 0.5.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,14 +40,20 @@ describe Aerosol::Connection do
40
40
 
41
41
  context 'when the host is an instance' do
42
42
  let(:public_hostname) { nil }
43
+ let(:host) { Aerosol::Instance.new }
43
44
  subject do
44
45
  Aerosol::Connection.new.tap do |inst|
45
46
  inst.name :connection_for_tim_horton
46
47
  inst.user 'tim_horton'
47
- inst.host double(:host, :public_hostname => public_hostname, :private_ip_address => '152.60.94.125')
48
+ inst.host host
48
49
  end
49
50
  end
50
51
 
52
+ before do
53
+ allow(host).to receive(:public_hostname).and_return(public_hostname)
54
+ allow(host).to receive(:private_ip_address).and_return('152.60.94.125')
55
+ end
56
+
51
57
  context 'when the public_hostname is present' do
52
58
  let(:public_hostname) { 'example.com' }
53
59
  it 'returns the public_hostname' do
@@ -66,7 +72,7 @@ describe Aerosol::Connection do
66
72
 
67
73
  context 'when the host is passed into with_connection' do
68
74
  let(:public_hostname) { nil }
69
- let(:host) { double(:host, :public_hostname => public_hostname, :private_ip_address => '152.60.94.125') }
75
+ let(:host) { Aerosol::Instance.new }
70
76
  subject do
71
77
  Aerosol::Connection.new.tap do |inst|
72
78
  inst.name :connection_for_tim_horton
@@ -74,6 +80,11 @@ describe Aerosol::Connection do
74
80
  end
75
81
  end
76
82
 
83
+ before do
84
+ allow(host).to receive(:public_hostname).and_return(public_hostname)
85
+ allow(host).to receive(:private_ip_address).and_return('152.60.94.125')
86
+ end
87
+
77
88
  context 'when the public_hostname is present' do
78
89
  let(:public_hostname) { 'example.com' }
79
90
  it 'returns the public_hostname' do
@@ -82,6 +93,14 @@ describe Aerosol::Connection do
82
93
  end
83
94
  end
84
95
 
96
+ context 'when the public_hostname is an empty string' do
97
+ let(:public_hostname) { '' }
98
+ it 'returns the private_ip_address' do
99
+ Net::SSH.should_receive(:start).with('152.60.94.125', 'tim_horton')
100
+ subject.with_connection(host)
101
+ end
102
+ end
103
+
85
104
  context 'when the public_hostname is nil' do
86
105
  it 'returns the private_ip_address' do
87
106
  Net::SSH.should_receive(:start).with('152.60.94.125', 'tim_horton')
@@ -79,12 +79,12 @@ describe Aerosol::Deploy do
79
79
 
80
80
  describe '#generate_ssh_command' do
81
81
  let(:ssh_ref) { double(:ssh_ref) }
82
- let(:instance) { double(:instance) }
82
+ let(:instance) { Aerosol::Instance.new }
83
83
  let(:ssh_command) { subject.generate_ssh_command(instance) }
84
84
 
85
85
  before do
86
- instance.stub(:public_hostname).and_return('hostname.com')
87
- subject.stub(:local_ssh_ref).and_return(ssh_ref)
86
+ allow(instance).to receive(:public_hostname).and_return('hostname.com')
87
+ allow(subject).to receive(:local_ssh_ref).and_return(ssh_ref)
88
88
  end
89
89
 
90
90
  context 'with a user' do
@@ -1,24 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Aerosol::Instance do
4
- let!(:launch_config) do
5
- Aerosol::LaunchConfiguration.new! do
6
- name :launch_config_for_instances
7
- ami 'ami-123-abc'
8
- instance_type 'm1.large'
9
- stub :sleep
10
- end
11
- end
12
-
13
- let!(:auto_scaling) do
14
- Aerosol::AutoScaling.new! do
15
- name :as_group_for_instances
16
- availability_zones 'us-east-2'
17
- launch_configuration :launch_config_for_instances
18
- min_size 10
19
- max_size 10
20
- stub :sleep
21
- end
4
+ let(:launch_configuration) do
5
+ Aerosol::LaunchConfiguration.new!({
6
+ name: 'launch_config_for_instances',
7
+ image_id: 'ami-123-abc',
8
+ instance_type: 'm1.large'
9
+ })
22
10
  end
23
11
 
24
12
  describe '.all' do
@@ -29,29 +17,62 @@ describe Aerosol::Instance do
29
17
  end
30
18
 
31
19
  context 'when there are instances' do
32
- before { launch_config.create; auto_scaling.create }
33
- after { launch_config.destroy; auto_scaling.destroy }
34
-
35
20
  it 'materializes each of them into an object' do
21
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_auto_scaling_instances, {
22
+ auto_scaling_instances: 10.times.map do |i|
23
+ {
24
+ instance_id: "i-#{1239013 + i}",
25
+ availability_zone: 'us-east-2',
26
+ lifecycle_state: 'InService',
27
+ health_status: 'GOOD',
28
+ launch_configuration_name: launch_configuration.launch_configuration_name.to_s,
29
+ auto_scaling_group_name: "test-#{i}"
30
+ }
31
+ end
32
+ })
36
33
  subject.length.should == 10
37
- subject.should be_all { |inst| inst.launch_configuration == launch_config }
34
+ subject.should be_all { |inst| inst.launch_configuration == launch_configuration }
38
35
  subject.should be_all { |inst| inst.availability_zone == 'us-east-2' }
39
36
  end
40
37
  end
41
38
  end
42
39
 
43
40
  describe '.description' do
44
- before { auto_scaling.create }
45
- after { auto_scaling.destroy }
46
-
47
41
  subject { described_class.all.first }
48
42
 
49
43
  it 'returns additional information about the instance' do
50
- subject.description['imageId'].should == launch_config.ami
51
- subject.description['instanceType'].should == launch_config.instance_type
52
- end
44
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_auto_scaling_instances, {
45
+ auto_scaling_instances: [
46
+ {
47
+ instance_id: 'i-1239013',
48
+ availability_zone: 'us-east-2',
49
+ lifecycle_state: 'InService',
50
+ health_status: 'GOOD',
51
+ launch_configuration_name: launch_configuration.launch_configuration_name.to_s,
52
+ auto_scaling_group_name: 'test'
53
+ }
54
+ ]
55
+ })
56
+ Aerosol::AWS.compute.stub_responses(:describe_instances, {
57
+ reservations: [{
58
+ instances: [{
59
+ instance_id: 'i-1239013',
60
+ image_id: launch_configuration.image_id,
61
+ instance_type: launch_configuration.instance_type,
62
+ public_dns_name: 'ec2-dns.aws.amazon.com',
63
+ private_ip_address: '10.0.0.1',
64
+ state: {
65
+ code: 99,
66
+ name: 'running'
67
+ }
68
+ }]
69
+ }]
70
+ })
53
71
 
54
- its(:public_hostname) { should_not be_nil }
55
- its(:private_ip_address) { should_not be_nil }
72
+ expect(subject.image_id).to eq(launch_configuration.image_id)
73
+ expect(subject.description[:instance_type]).to eq(launch_configuration.instance_type)
74
+ expect(subject.public_hostname).to_not be_nil
75
+ expect(subject.private_ip_address).to_not be_nil
76
+ end
56
77
  end
57
78
  end
@@ -4,7 +4,7 @@ describe Aerosol::LaunchConfiguration do
4
4
  subject do
5
5
  described_class.new do
6
6
  name :my_launch_config
7
- ami 'ami-123'
7
+ image_id 'ami-123'
8
8
  instance_type 'super-cool-instance-type'
9
9
  user_data <<-END_OF_STRING
10
10
  #!/bin/bash
@@ -14,11 +14,11 @@ describe Aerosol::LaunchConfiguration do
14
14
  end
15
15
  before { subject.stub(:sleep) }
16
16
 
17
- describe "#aws_identifier" do
17
+ describe "#launch_configuration_name" do
18
18
  context "with no namespace set" do
19
19
  let(:identifier) { "my_launch_config-#{Aerosol::Util.git_sha}" }
20
20
  it "returns a normal identifier" do
21
- expect(subject.aws_identifier).to eq(identifier)
21
+ expect(subject.launch_configuration_name).to eq(identifier)
22
22
  end
23
23
  end
24
24
 
@@ -30,7 +30,7 @@ describe Aerosol::LaunchConfiguration do
30
30
  after { Aerosol.instance_variable_set(:"@namespace", nil) }
31
31
 
32
32
  it "returns a namespaced identifier" do
33
- expect(subject.aws_identifier).to eq(identifier)
33
+ expect(subject.launch_configuration_name).to eq(identifier)
34
34
  end
35
35
  end
36
36
  end
@@ -52,7 +52,7 @@ describe Aerosol::LaunchConfiguration do
52
52
 
53
53
  describe '#create!' do
54
54
  context 'when some required fields are nil' do
55
- before { subject.instance_variable_set(:@ami, nil) }
55
+ before { subject.instance_variable_set(:@image_id, nil) }
56
56
 
57
57
  it 'raises an error' do
58
58
  expect { subject.create! }.to raise_error
@@ -61,10 +61,11 @@ describe Aerosol::LaunchConfiguration do
61
61
 
62
62
  context 'when everything is present' do
63
63
  context 'and the launch configuration already exists' do
64
- before { subject.create! rescue nil }
65
- after { subject.destroy! rescue nil }
66
-
67
64
  it 'raises an error' do
65
+ Aerosol::AWS.auto_scaling.stub_responses(
66
+ :create_launch_configuration,
67
+ Aws::AutoScaling::Errors::AlreadyExists
68
+ )
68
69
  expect { subject.create! }.to raise_error
69
70
  end
70
71
  end
@@ -73,41 +74,37 @@ describe Aerosol::LaunchConfiguration do
73
74
  after { subject.destroy! rescue nil }
74
75
 
75
76
  it 'creates the launch configuration group' do
77
+ Aerosol::AWS.auto_scaling.stub_responses(:create_launch_configuration, [])
76
78
  expect { subject.create! }.to_not raise_error
77
79
  end
78
-
79
- it 'fixes the user data spacing' do
80
- subject.send(:conn).should_receive(:create_launch_configuration)
81
- .with('ami-123', 'super-cool-instance-type',
82
- subject.aws_identifier,
83
- 'SecurityGroups' => [],
84
- 'UserData' => "#!/bin/bash\nrm -rf /\n")
85
- subject.create!
86
- end
87
80
  end
88
81
  end
89
82
  end
90
83
 
91
84
  describe '#destroy!' do
92
- context 'when the aws_identifier is nil' do
93
- before { subject.instance_variable_set(:@aws_identifier, nil) }
85
+ context 'when the launch_configuration_name is nil' do
94
86
 
95
87
  it 'raises an error' do
88
+ allow(subject).to receive(:launch_configuration_name).and_return(nil)
89
+ Aerosol::AWS.auto_scaling.stub_responses(:delete_launch_configuration, [])
96
90
  expect { subject.destroy! }.to raise_error
97
91
  end
98
92
  end
99
93
 
100
- context 'when the aws_identifier is present' do
94
+ context 'when the launch_configuration_name is present' do
101
95
  context 'but the launch configuration does not exist' do
102
96
  it 'raises an error' do
97
+ Aerosol::AWS.auto_scaling.stub_responses(
98
+ :delete_launch_configuration,
99
+ Aws::AutoScaling::Errors::ValidationError
100
+ )
103
101
  expect { subject.destroy! }.to raise_error
104
102
  end
105
103
  end
106
104
 
107
105
  context 'and the launch configuration exists' do
108
- before { subject.create! }
109
-
110
106
  it 'deletes the launch configuration' do
107
+ Aerosol::AWS.auto_scaling.stub_responses(:delete_launch_configuration, [])
111
108
  expect { subject.destroy! }.to_not raise_error
112
109
  end
113
110
  end
@@ -115,36 +112,56 @@ describe Aerosol::LaunchConfiguration do
115
112
  end
116
113
 
117
114
  describe '#create' do
118
- context 'when the aws_identifier is nil' do
119
- subject { described_class.new!(:name => :random_test_name) }
115
+ context 'when the launch_configuration_name is nil' do
116
+ subject do
117
+ described_class.new! do
118
+ name :random_test_name
119
+ image_id 'test-ami-who-even-cares-really'
120
+ instance_type 'm1.large'
121
+ end
122
+ end
120
123
 
121
124
  it 'raises an error' do
125
+ allow(subject).to receive(:launch_configuration_name).and_return(nil)
126
+ Aerosol::AWS.auto_scaling.stub_responses(:create_launch_configuration, [])
127
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
128
+ launch_configurations: [], next_token: nil
129
+ })
122
130
  expect { subject.create }.to raise_error
123
131
  end
124
132
  end
125
133
 
126
- context 'when the aws_identifier is present' do
134
+ context 'when the launch_configuration_name is present' do
127
135
  subject do
128
136
  described_class.new! do
129
137
  name :random_test_name_2
130
- ami 'test-ami-who-even-cares-really'
138
+ image_id 'test-ami-who-even-cares-really'
131
139
  instance_type 'm1.large'
132
140
  end
133
141
  end
134
142
 
135
143
  context 'but the launch configuration already exists' do
136
- before { subject.create! }
137
-
138
144
  it 'does not call #create!' do
139
- subject.should_not_receive(:create!)
145
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
146
+ launch_configurations: [{
147
+ launch_configuration_name: subject.launch_configuration_name,
148
+ image_id: 'ami-1235535',
149
+ instance_type: 'm3.large',
150
+ created_time: Time.at(1)
151
+ }],
152
+ next_token: nil
153
+ })
154
+ expect(subject).to_not receive(:create!)
140
155
  subject.create
141
156
  end
142
157
  end
143
158
 
144
159
  context 'and the launch configuration does not yet exist' do
145
- before { subject.destroy }
146
-
147
160
  it 'creates it' do
161
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
162
+ launch_configurations: [],
163
+ next_token: nil
164
+ })
148
165
  subject.should_receive(:create!)
149
166
  subject.create
150
167
  end
@@ -153,36 +170,49 @@ describe Aerosol::LaunchConfiguration do
153
170
  end
154
171
 
155
172
  describe '#destroy' do
156
- context 'when the aws_identifier is nil' do
157
- subject { described_class.new!(:name => :random_test_name_3) }
158
-
159
- it 'raises an error' do
160
- expect { subject.create }.to raise_error
173
+ subject do
174
+ described_class.new! do
175
+ name :random_test_name_3
176
+ image_id 'awesome-ami'
177
+ instance_type 'm1.large'
161
178
  end
162
179
  end
163
180
 
164
- context 'when the aws_identifier is present' do
165
- subject do
166
- described_class.new! do
167
- name :random_test_name_4
168
- ami 'awesome-ami'
169
- instance_type 'm1.large'
170
- end
181
+ context 'when the launch_configuration_name is nil' do
182
+ it 'raises an error' do
183
+ allow(subject).to receive(:launch_configuration_name).and_return(nil)
184
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
185
+ launch_configurations: [],
186
+ next_token: nil
187
+ })
188
+ expect { subject.create }.to raise_error(ArgumentError)
171
189
  end
190
+ end
172
191
 
192
+ context 'when the launch_configuration_name is present' do
173
193
  context 'and the launch configuration already exists' do
174
- before { subject.create! }
175
194
 
176
195
  it 'calls #destroy!' do
196
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
197
+ launch_configurations: [{
198
+ launch_configuration_name: subject.launch_configuration_name,
199
+ image_id: 'ami-1235535',
200
+ instance_type: 'm3.large',
201
+ created_time: Time.at(1)
202
+ }],
203
+ next_token: nil
204
+ })
177
205
  subject.should_receive(:destroy!)
178
206
  subject.destroy
179
207
  end
180
208
  end
181
209
 
182
210
  context 'but the launch configuration does not yet exist' do
183
- before { subject.destroy! rescue nil }
184
-
185
211
  it 'does not call #destroy!' do
212
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
213
+ launch_configurations: [],
214
+ next_token: nil
215
+ })
186
216
  subject.should_not_receive(:destroy!)
187
217
  subject.destroy
188
218
  end
@@ -192,19 +222,27 @@ describe Aerosol::LaunchConfiguration do
192
222
 
193
223
  describe '.exists?' do
194
224
  subject { described_class }
195
-
196
- context 'when the argument exists' do
197
- let(:instance) do
198
- subject.new! do
199
- name :exists_test_name
200
- ami 'ami123'
201
- instance_type 'm1.large'
202
- stub(:sleep)
203
- end.tap(&:create!)
225
+ let(:instance) do
226
+ subject.new! do
227
+ name :exists_test_name
228
+ image_id 'ami123'
229
+ instance_type 'm1.large'
230
+ stub(:sleep)
204
231
  end
232
+ end
205
233
 
234
+ context 'when the argument exists' do
206
235
  it 'returns true' do
207
- subject.exists?(instance.aws_identifier).should be_true
236
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
237
+ launch_configurations: [{
238
+ launch_configuration_name: instance.launch_configuration_name,
239
+ image_id: 'ami-1235535',
240
+ instance_type: 'm3.large',
241
+ created_time: Time.at(1)
242
+ }],
243
+ next_token: nil
244
+ })
245
+ subject.exists?(instance.launch_configuration_name).should be_true
208
246
  end
209
247
  end
210
248
 
@@ -212,25 +250,53 @@ describe Aerosol::LaunchConfiguration do
212
250
  let(:instance) { described_class.new! }
213
251
 
214
252
  it 'returns false' do
215
- subject.exists?(instance.aws_identifier).should be_false
253
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
254
+ launch_configurations: [],
255
+ next_token: nil
256
+ })
257
+ subject.exists?(instance.launch_configuration_name).should be_false
216
258
  end
217
259
  end
218
260
  end
219
261
 
220
262
  describe '.request_all' do
221
263
  describe 'repeats until no NextToken' do
222
- before do
223
- allow(Aerosol::LaunchConfiguration).to receive(:request_all_for_token).with(nil) do
224
- { 'LaunchConfigurations' => [1, 4], 'NextToken' => 'token' }
225
- end
226
-
227
- allow(Aerosol::LaunchConfiguration).to receive(:request_all_for_token).with('token') do
228
- { 'LaunchConfigurations' => [2, 3], 'NextToken' => nil }
229
- end
230
- end
231
-
232
264
  it 'should include both autoscaling groups lists' do
233
- expect(Aerosol::LaunchConfiguration.request_all).to eq([1,4,2,3])
265
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, [
266
+ {
267
+ launch_configurations: [
268
+ {
269
+ launch_configuration_name: '1',
270
+ image_id: 'ami-1235535',
271
+ instance_type: 'm3.large',
272
+ created_time: Time.at(1)
273
+ }, {
274
+ launch_configuration_name: '4',
275
+ image_id: 'ami-1235535',
276
+ instance_type: 'm3.large',
277
+ created_time: Time.at(1)
278
+ }
279
+ ],
280
+ next_token: 'yes'
281
+ },
282
+ {
283
+ launch_configurations: [
284
+ {
285
+ launch_configuration_name: '2',
286
+ image_id: 'ami-1235535',
287
+ instance_type: 'm3.large',
288
+ created_time: Time.at(1)
289
+ }, {
290
+ launch_configuration_name: '3',
291
+ image_id: 'ami-1235535',
292
+ instance_type: 'm3.large',
293
+ created_time: Time.at(1)
294
+ }
295
+ ],
296
+ next_token: nil
297
+ }
298
+ ])
299
+ expect(Aerosol::LaunchConfiguration.request_all.map(&:launch_configuration_name)).to eq(['1','4','2','3'])
234
300
  end
235
301
  end
236
302
  end
@@ -238,37 +304,39 @@ describe Aerosol::LaunchConfiguration do
238
304
  describe '.all' do
239
305
  subject { described_class }
240
306
 
241
- def destroy_all
242
- Aerosol::LaunchConfiguration.instances.values.each do |instance|
243
- instance.destroy! rescue nil
244
- end
245
- end
246
-
247
- after { destroy_all }
248
-
249
307
  context 'when there are no launch configurations' do
250
- before { destroy_all }
251
-
308
+ before do
309
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, [
310
+ { launch_configurations: [], next_token: nil }
311
+ ])
312
+ end
252
313
  its(:all) { should be_empty }
253
314
  end
254
315
 
255
316
  context 'when there are launch configurations' do
256
-
257
- before do
317
+ let(:insts) {
258
318
  [
259
319
  {
260
- :ami => 'ami1',
261
- :instance_type => 'm1.large'
320
+ launch_configuration_name: 'test',
321
+ image_id: 'ami1',
322
+ instance_type: 'm1.large',
323
+ created_time: Time.at(1)
262
324
  },
263
325
  {
264
- :ami => 'ami2',
265
- :instance_type => 'm1.large'
326
+ launch_configuration_name: 'test2',
327
+ image_id: 'ami2',
328
+ instance_type: 'm1.large',
329
+ created_time: Time.at(1)
266
330
  }
267
- ].each { |hash| subject.new!(hash).tap { |inst| inst.stub(:sleep) }.create! }
268
- end
331
+ ]
332
+ }
269
333
 
270
334
  it 'returns each of them' do
271
- subject.all.map(&:ami).should == %w[ami1 ami2]
335
+ Aerosol::AWS.auto_scaling.stub_responses(:describe_launch_configurations, {
336
+ launch_configurations: insts,
337
+ next_token: nil
338
+ })
339
+ subject.all.map(&:image_id).should == %w[ami1 ami2]
272
340
  subject.all.map(&:instance_type).should == %w[m1.large m1.large]
273
341
  end
274
342
  end
@@ -279,27 +347,28 @@ describe Aerosol::LaunchConfiguration do
279
347
  subject { described_class.from_hash(hash) }
280
348
  let(:hash) do
281
349
  {
282
- 'LaunchConfigurationName' => '~test-launch-config~',
283
- 'ImageId' => 'ami-123',
284
- 'InstanceType' => 'm1.large',
285
- 'SecurityGroups' => [],
286
- 'UserData' => 'echo hi',
287
- 'IamInstanceProfile' => nil,
288
- 'KernelId' => 'kernel-id',
289
- 'KeyName' => 'key-name',
290
- 'SpotPrice' => '0.04',
350
+ launch_configuration_name: '~test-launch-config~',
351
+ image_id: 'ami-123',
352
+ instance_type: 'm1.large',
353
+ security_groups: [],
354
+ user_data: 'echo hi',
355
+ iam_instance_profile: nil,
356
+ kernel_id: 'kernel-id',
357
+ key_name: 'key-name',
358
+ spot_price: '0.04',
291
359
  }
292
360
  end
293
361
 
294
362
  it 'creates a new launch configuration with the specified values' do
295
- subject.aws_identifier.should == '~test-launch-config~'
296
- subject.ami.should == 'ami-123'
363
+ subject.launch_configuration_name.should == '~test-launch-config~'
364
+ subject.image_id.should == 'ami-123'
297
365
  subject.instance_type.should == 'm1.large'
298
366
  subject.security_groups.should be_empty
299
367
  subject.user_data.should == 'echo hi'
300
- subject.iam_role.should be_nil
368
+ subject.iam_instance_profile.should be_nil
301
369
  subject.kernel_id.should == 'kernel-id'
302
370
  subject.spot_price.should == '0.04'
371
+ subject.from_aws = true
303
372
  end
304
373
 
305
374
  it 'generates a name' do
@@ -310,18 +379,18 @@ describe Aerosol::LaunchConfiguration do
310
379
  context 'when the launch configuration has already been initialized' do
311
380
  let(:old_hash) do
312
381
  {
313
- 'LaunchConfigurationName' => 'this-aws-id-abc-123',
314
- 'ImageId' => 'ami-456',
382
+ launch_configuration_name: 'this-aws-id-abc-123',
383
+ image_id: 'ami-456',
315
384
  }
316
385
  end
317
- let(:new_hash) { old_hash.merge('InstanceType' => 'm1.large') }
386
+ let(:new_hash) { old_hash.merge(instance_type: 'm1.large') }
318
387
  let!(:existing) { described_class.from_hash(old_hash) }
319
388
  let(:new) { described_class.from_hash(new_hash) }
320
389
 
321
- it 'updates its values' do
390
+ it 'makes a new instance' do
322
391
  expect { new }.to change { described_class.instances.length }.by(1)
323
- new.aws_identifier.should == 'this-aws-id-abc-123'
324
- new.ami.should == 'ami-456'
392
+ new.launch_configuration_name.should == 'this-aws-id-abc-123'
393
+ new.image_id.should == 'ami-456'
325
394
  end
326
395
  end
327
396
  end