cf 1.1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/lib/cf/cli/start/login.rb +3 -0
  2. data/lib/cf/version.rb +1 -1
  3. data/spec/cf/cli/app/base_spec.rb +2 -2
  4. data/spec/cf/cli/app/delete_spec.rb +150 -129
  5. data/spec/cf/cli/app/instances_spec.rb +56 -51
  6. data/spec/cf/cli/app/push/create_spec.rb +72 -70
  7. data/spec/cf/cli/app/push_spec.rb +46 -43
  8. data/spec/cf/cli/app/rename_spec.rb +13 -6
  9. data/spec/cf/cli/app/scale_spec.rb +9 -4
  10. data/spec/cf/cli/app/start_spec.rb +28 -23
  11. data/spec/cf/cli/app/stats_spec.rb +9 -10
  12. data/spec/cf/cli/domain/map_spec.rb +13 -10
  13. data/spec/cf/cli/domain/unmap_spec.rb +11 -11
  14. data/spec/cf/cli/organization/delete_spec.rb +10 -4
  15. data/spec/cf/cli/organization/orgs_spec.rb +15 -4
  16. data/spec/cf/cli/organization/rename_spec.rb +7 -5
  17. data/spec/cf/cli/populators/organization_spec.rb +40 -29
  18. data/spec/cf/cli/populators/space_spec.rb +51 -40
  19. data/spec/cf/cli/populators/target_spec.rb +4 -2
  20. data/spec/cf/cli/route/delete_spec.rb +6 -4
  21. data/spec/cf/cli/route/map_spec.rb +54 -35
  22. data/spec/cf/cli/route/unmap_spec.rb +21 -15
  23. data/spec/cf/cli/service/create_spec.rb +17 -12
  24. data/spec/cf/cli/service/rename_spec.rb +8 -6
  25. data/spec/cf/cli/service/services_spec.rb +15 -8
  26. data/spec/cf/cli/space/create_spec.rb +5 -9
  27. data/spec/cf/cli/space/delete_spec.rb +9 -8
  28. data/spec/cf/cli/space/rename_spec.rb +15 -8
  29. data/spec/cf/cli/space/space_spec.rb +10 -10
  30. data/spec/cf/cli/space/spaces_spec.rb +11 -5
  31. data/spec/cf/cli/space/switch_space_spec.rb +7 -7
  32. data/spec/cf/cli/start/info_spec.rb +3 -1
  33. data/spec/cf/cli/start/login_spec.rb +1 -1
  34. data/spec/cf/cli/start/logout_spec.rb +1 -1
  35. data/spec/cf/cli/start/target_spec.rb +7 -6
  36. data/spec/cf/cli/user/create_spec.rb +3 -4
  37. data/spec/cf/cli/user/passwd_spec.rb +2 -4
  38. data/spec/cf/cli/user/register_spec.rb +4 -4
  39. data/spec/cf/cli_spec.rb +1 -3
  40. data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
  41. data/spec/factories/cfoundry/v2/clients_factory.rb +4 -0
  42. data/spec/factories/cfoundry/v2/{domain_factory.rb → domains_factory.rb} +0 -0
  43. data/spec/factories/cfoundry/v2/organizations_factory.rb +12 -0
  44. data/spec/factories/cfoundry/v2/{route_factory.rb → routes_factory.rb} +0 -0
  45. data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
  46. data/spec/factories/cfoundry/v2/service_instances_factory.rb +12 -0
  47. data/spec/factories/cfoundry/v2/service_plans_factory.rb +13 -0
  48. data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
  49. data/spec/factories/cfoundry/v2/spaces_factory.rb +12 -0
  50. data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
  51. data/spec/factories/cfoundry/v2/{user_factory.rb → users_factory.rb} +0 -0
  52. data/spec/features/push_flow_spec.rb +8 -8
  53. data/spec/manifests/manifests_spec.rb +34 -51
  54. data/spec/manifests/plugin_spec.rb +17 -6
  55. data/spec/spec_helper.rb +0 -1
  56. data/spec/support/interact_helper.rb +1 -1
  57. data/spec/tunnel/tunnel_spec.rb +5 -5
  58. metadata +37 -13
@@ -7,30 +7,32 @@ module CF
7
7
  let(:given) { {} }
8
8
  let(:global) { {:color => false, :quiet => true} }
9
9
 
10
- let(:service_instances) { fake_list(:service_instance, 5) }
11
- let(:lucid64) { fake :stack, :name => "lucid64" }
12
-
13
- let(:client) do
14
- fake_client(:service_instances => service_instances, :stacks => [lucid64])
15
- end
10
+ let(:service_instances) { Array.new(5) { build(:service_instance) } }
11
+ let(:lucid64) { build(:stack, :name => "lucid64") }
12
+ let(:client) { build(:client) }
16
13
 
17
14
  before do
18
15
  CF::CLI.any_instance.stub(:client).and_return(client)
16
+ client.stub(:service_instances).and_return(service_instances)
17
+ client.stub(:stacks).and_return([lucid64])
19
18
  end
20
19
 
21
20
  let(:path) { "some-path" }
22
21
 
23
- subject(:create) do
22
+
23
+ def setup_create
24
24
  command = Mothership.commands[:push]
25
- create = CF::App::Push.new(command)
26
- create.path = path
27
- create.input = Mothership::Inputs.new(command, create, inputs, given, global)
28
- create.extend CF::App::PushInteractions
29
- create
25
+ push_command = CF::App::Push.new(command)
26
+ push_command.path = path
27
+ push_command.input = Mothership::Inputs.new(command, push_command, inputs, given, global)
28
+ push_command.extend CF::App::PushInteractions
29
+ push_command
30
30
  end
31
31
 
32
+ let(:push_command) { setup_create }
33
+
32
34
  describe "#get_inputs" do
33
- subject { create.get_inputs }
35
+ subject { push_command.get_inputs }
34
36
 
35
37
  let(:given) do
36
38
  {:name => "some-name",
@@ -75,13 +77,13 @@ module CF
75
77
  context "when certain inputs are not given" do
76
78
  it "asks for the name" do
77
79
  given.delete(:name)
78
- mock_ask("Name") { "some-name" }
80
+ should_ask("Name") { "some-name" }
79
81
  subject
80
82
  end
81
83
 
82
84
  it "asks for the total instances" do
83
85
  given.delete(:instances)
84
- mock_ask("Instances", anything) { 1 }
86
+ should_ask("Instances", anything) { 1 }
85
87
  subject
86
88
  end
87
89
 
@@ -90,7 +92,7 @@ module CF
90
92
 
91
93
  shared_examples "an app that can have a custom start command" do
92
94
  it "asks for a start command with a default as 'none'" do
93
- mock_ask("Custom startup command", :default => "none") do
95
+ should_ask("Custom startup command", :default => "none") do
94
96
  "abcd"
95
97
  end
96
98
 
@@ -136,7 +138,7 @@ module CF
136
138
 
137
139
  context "when there is no Procfile in the app's root" do
138
140
  it "asks for a start command" do
139
- mock_ask("Custom startup command", :default => "none")
141
+ should_ask("Custom startup command", :default => "none")
140
142
  subject
141
143
  end
142
144
  end
@@ -147,9 +149,9 @@ module CF
147
149
  given.delete(:memory)
148
150
 
149
151
  memory_choices = %w(64M 128M 256M 512M 1G)
150
- create.stub(:memory_choices).and_return(memory_choices)
152
+ push_command.stub(:memory_choices).and_return(memory_choices)
151
153
 
152
- mock_ask("Memory Limit", anything) do |_, options|
154
+ should_ask("Memory Limit", anything) do |_, options|
153
155
  expect(options[:choices]).to eq memory_choices
154
156
  expect(options[:default]).to eq "256M"
155
157
  "1G"
@@ -179,7 +181,7 @@ module CF
179
181
  client.stub(:current_space).and_return(space)
180
182
  end
181
183
 
182
- subject { create.create_app(attributes) }
184
+ subject { push_command.create_app(attributes) }
183
185
 
184
186
  context "when the user does not have permission to create apps" do
185
187
  it "fails with a friendly message" do
@@ -201,7 +203,7 @@ module CF
201
203
  end
202
204
 
203
205
  it "fails and prints a pretty message" do
204
- create.stub(:line).with(anything)
206
+ push_command.stub(:line).with(anything)
205
207
  expect { subject }.to raise_error(
206
208
  CF::UserError, "Buildpack must be a public git repository URI.")
207
209
  end
@@ -214,10 +216,10 @@ module CF
214
216
  let(:domains) { [double(:domain, :name => "foo.com")] }
215
217
  let(:hosts) { [app.name] }
216
218
 
217
- subject { create.map_route(app) }
219
+ subject { push_command.map_route(app) }
218
220
 
219
221
  it "asks for a subdomain with 'none' as an option" do
220
- mock_ask("Subdomain", anything) do |_, options|
222
+ should_ask("Subdomain", anything) do |_, options|
221
223
  expect(options[:choices]).to eq(hosts + %w(none))
222
224
  expect(options[:default]).to eq hosts.first
223
225
  hosts.first
@@ -225,7 +227,7 @@ module CF
225
227
 
226
228
  stub_ask("Domain", anything) { domains.first }
227
229
 
228
- create.stub(:invoke)
230
+ push_command.stub(:invoke)
229
231
 
230
232
  subject
231
233
  end
@@ -233,13 +235,13 @@ module CF
233
235
  it "asks for a domain with 'none' as an option" do
234
236
  stub_ask("Subdomain", anything) { hosts.first }
235
237
 
236
- mock_ask("Domain", anything) do |_, options|
238
+ should_ask("Domain", anything) do |_, options|
237
239
  expect(options[:choices]).to eq(domains + %w(none))
238
240
  expect(options[:default]).to eq domains.first
239
241
  domains.first
240
242
  end
241
243
 
242
- create.stub(:invoke)
244
+ push_command.stub(:invoke)
243
245
 
244
246
  subject
245
247
  end
@@ -248,7 +250,7 @@ module CF
248
250
  stub_ask("Subdomain", anything) { hosts.first }
249
251
  stub_ask("Domain", anything) { domains.first }
250
252
 
251
- create.should_receive(:invoke).with(:map,
253
+ push_command.should_receive(:invoke).with(:map,
252
254
  :app => app, :host => hosts.first,
253
255
  :domain => domains.first)
254
256
 
@@ -258,10 +260,10 @@ module CF
258
260
  context "when 'none' is given as the host" do
259
261
  context "and a domain is provided afterwards" do
260
262
  it "invokes 'map' with an empty host" do
261
- mock_ask("Subdomain", anything) { "none" }
263
+ should_ask("Subdomain", anything) { "none" }
262
264
  stub_ask("Domain", anything) { domains.first }
263
265
 
264
- create.should_receive(:invoke).with(:map,
266
+ push_command.should_receive(:invoke).with(:map,
265
267
  :host => "", :domain => domains.first, :app => app)
266
268
 
267
269
  subject
@@ -272,9 +274,9 @@ module CF
272
274
  context "when 'none' is given as the domain" do
273
275
  it "does not perform any mapping" do
274
276
  stub_ask("Subdomain", anything) { "foo" }
275
- mock_ask("Domain", anything) { "none" }
277
+ should_ask("Domain", anything) { "none" }
276
278
 
277
- create.should_not_receive(:invoke).with(:map, anything)
279
+ push_command.should_not_receive(:invoke).with(:map, anything)
278
280
 
279
281
  subject
280
282
  end
@@ -282,34 +284,34 @@ module CF
282
284
 
283
285
  context "when mapping fails" do
284
286
  before do
285
- mock_ask("Subdomain", anything) { "foo" }
286
- mock_ask("Domain", anything) { domains.first }
287
+ should_ask("Subdomain", anything) { "foo" }
288
+ should_ask("Domain", anything) { domains.first }
287
289
 
288
- create.should_receive(:invoke).with(:map,
290
+ push_command.should_receive(:invoke).with(:map,
289
291
  :host => "foo", :domain => domains.first, :app => app) do
290
292
  raise CFoundry::RouteHostTaken.new("foo", 1234)
291
293
  end
292
294
  end
293
295
 
294
296
  it "asks again" do
295
- create.stub(:line)
297
+ push_command.stub(:line)
296
298
 
297
- mock_ask("Subdomain", anything) { hosts.first }
298
- mock_ask("Domain", anything) { domains.first }
299
+ should_ask("Subdomain", anything) { hosts.first }
300
+ should_ask("Domain", anything) { domains.first }
299
301
 
300
- create.stub(:invoke)
302
+ push_command.stub(:invoke)
301
303
 
302
304
  subject
303
305
  end
304
306
 
305
307
  it "reports the failure message" do
306
- create.should_receive(:line).with("foo")
307
- create.should_receive(:line)
308
+ push_command.should_receive(:line).with("foo")
309
+ push_command.should_receive(:line)
308
310
 
309
311
  stub_ask("Subdomain", anything) { hosts.first }
310
312
  stub_ask("Domain", anything) { domains.first }
311
313
 
312
- create.stub(:invoke)
314
+ push_command.stub(:invoke)
313
315
 
314
316
  subject
315
317
  end
@@ -317,8 +319,8 @@ module CF
317
319
  end
318
320
 
319
321
  describe "#create_services" do
320
- let(:app) { fake(:app) }
321
- subject { create.create_services(app) }
322
+ let(:app) { build(:app, :client => client) }
323
+ subject { push_command.create_services(app) }
322
324
 
323
325
  context "when forcing" do
324
326
  let(:inputs) { {:force => true} }
@@ -329,7 +331,7 @@ module CF
329
331
  end
330
332
 
331
333
  it "does not create any services" do
332
- create.should_not_receive(:invoke).with(:create_service, anything)
334
+ push_command.should_not_receive(:invoke).with(:create_service, anything)
333
335
  subject
334
336
  end
335
337
  end
@@ -338,24 +340,24 @@ module CF
338
340
  let(:inputs) { {:force => false} }
339
341
 
340
342
  it "does not create the service if asked not to" do
341
- mock_ask("Create services for application?", anything) { false }
342
- create.should_not_receive(:invoke).with(:create_service, anything)
343
+ should_ask("Create services for application?", anything) { false }
344
+ push_command.should_not_receive(:invoke).with(:create_service, anything)
343
345
 
344
346
  subject
345
347
  end
346
348
 
347
349
  it "asks again to create a service" do
348
- mock_ask("Create services for application?", anything) { true }
349
- create.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
350
+ should_ask("Create services for application?", anything) { true }
351
+ push_command.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
350
352
 
351
- mock_ask("Create another service?", :default => false) { true }
352
- create.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
353
+ should_ask("Create another service?", :default => false) { true }
354
+ push_command.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
353
355
 
354
- mock_ask("Create another service?", :default => false) { true }
355
- create.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
356
+ should_ask("Create another service?", :default => false) { true }
357
+ push_command.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
356
358
 
357
- mock_ask("Create another service?", :default => false) { false }
358
- create.should_not_receive(:invoke).with(:create_service, anything).ordered
359
+ should_ask("Create another service?", :default => false) { false }
360
+ push_command.should_not_receive(:invoke).with(:create_service, anything).ordered
359
361
 
360
362
  subject
361
363
  end
@@ -365,7 +367,7 @@ module CF
365
367
  describe "#bind_services" do
366
368
  let(:app) { double(:app).as_null_object }
367
369
 
368
- subject { create.bind_services(app) }
370
+ subject { push_command.bind_services(app) }
369
371
 
370
372
  context "when forcing" do
371
373
  let(:global) { {:force => true, :color => false, :quiet => true} }
@@ -376,15 +378,15 @@ module CF
376
378
  end
377
379
 
378
380
  it "does not bind any services" do
379
- create.should_not_receive(:invoke).with(:bind_service, anything)
381
+ push_command.should_not_receive(:invoke).with(:bind_service, anything)
380
382
  subject
381
383
  end
382
384
  end
383
385
 
384
386
  context "when not forcing" do
385
387
  it "does not bind the service if asked not to" do
386
- mock_ask("Bind other services to application?", anything) { false }
387
- create.should_not_receive(:invoke).with(:bind_service, anything)
388
+ should_ask("Bind other services to application?", anything) { false }
389
+ push_command.should_not_receive(:invoke).with(:bind_service, anything)
388
390
 
389
391
  subject
390
392
  end
@@ -393,14 +395,14 @@ module CF
393
395
  bind_times = 3
394
396
  call_count = 0
395
397
 
396
- mock_ask("Bind other services to application?", anything) { true }
398
+ should_ask("Bind other services to application?", anything) { true }
397
399
 
398
- create.should_receive(:invoke).with(:bind_service, :app => app).exactly(bind_times).times do
400
+ push_command.should_receive(:invoke).with(:bind_service, :app => app).exactly(bind_times).times do
399
401
  call_count += 1
400
402
  app.stub(:services).and_return(service_instances.first(call_count))
401
403
  end
402
404
 
403
- mock_ask("Bind another service?", anything).exactly(bind_times).times do
405
+ should_ask("Bind another service?", anything).exactly(bind_times).times do
404
406
  call_count < bind_times
405
407
  end
406
408
 
@@ -411,14 +413,14 @@ module CF
411
413
  bind_times = service_instances.size
412
414
  call_count = 0
413
415
 
414
- mock_ask("Bind other services to application?", anything) { true }
416
+ should_ask("Bind other services to application?", anything) { true }
415
417
 
416
- create.should_receive(:invoke).with(:bind_service, :app => app).exactly(bind_times).times do
418
+ push_command.should_receive(:invoke).with(:bind_service, :app => app).exactly(bind_times).times do
417
419
  call_count += 1
418
420
  app.stub(:services).and_return(service_instances.first(call_count))
419
421
  end
420
422
 
421
- mock_ask("Bind another service?", anything).exactly(bind_times-1).times { true }
423
+ should_ask("Bind another service?", anything).exactly(bind_times-1).times { true }
422
424
 
423
425
  subject
424
426
  end
@@ -435,14 +437,14 @@ module CF
435
437
  end
436
438
 
437
439
  describe "#start_app" do
438
- let(:app) { fake(:app) }
439
- subject { create.start_app(app) }
440
+ let(:app) { build(:app, :client => client) }
441
+ subject { push_command.start_app(app) }
440
442
 
441
443
  context "when the start flag is provided" do
442
444
  let(:inputs) { {:start => true} }
443
445
 
444
446
  it "invokes the start command" do
445
- create.should_receive(:invoke).with(:start, :app => app)
447
+ push_command.should_receive(:invoke).with(:start, :app => app)
446
448
  subject
447
449
  end
448
450
  end
@@ -451,7 +453,7 @@ module CF
451
453
  let(:inputs) { {:start => false} }
452
454
 
453
455
  it "invokes the start command" do
454
- create.should_not_receive(:invoke).with(:start, anything)
456
+ push_command.should_not_receive(:invoke).with(:start, anything)
455
457
  subject
456
458
  end
457
459
  end
@@ -472,7 +474,7 @@ module CF
472
474
  end
473
475
 
474
476
  it "asks for the memory with the ceiling taking the memory usage into account" do
475
- expect(subject.memory_choices).to eq(%w[64M 128M 256M 512M 1G])
477
+ expect(push_command.memory_choices).to eq(%w[64M 128M 256M 512M 1G])
476
478
  end
477
479
  end
478
480
 
@@ -480,7 +482,7 @@ module CF
480
482
  let(:info) { {:limits => {:memory => 2048}} }
481
483
 
482
484
  it "asks for the memory with the ceiling as their overall limit" do
483
- expect(subject.memory_choices).to eq(%w[64M 128M 256M 512M 1G 2G])
485
+ expect(push_command.memory_choices).to eq(%w[64M 128M 256M 512M 1G 2G])
484
486
  end
485
487
  end
486
488
  end
@@ -7,7 +7,7 @@ module CF
7
7
  let(:inputs) { {} }
8
8
  let(:given) { {} }
9
9
  let(:path) { "somepath" }
10
- let(:client) { fake_client }
10
+ let(:client) { build(:client) }
11
11
  let(:push) { CF::App::Push.new(Mothership.commands[:push]) }
12
12
 
13
13
  before do
@@ -15,27 +15,27 @@ module CF
15
15
  CF::CLI.any_instance.stub(:precondition) { nil }
16
16
  end
17
17
 
18
- describe 'metadata' do
18
+ describe "metadata" do
19
19
  let(:command) { Mothership.commands[:push] }
20
20
 
21
- describe 'command' do
21
+ describe "command" do
22
22
  subject { command }
23
23
  its(:description) { should eq "Push an application, syncing changes if it exists" }
24
24
  it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
25
25
  end
26
26
 
27
- include_examples 'inputs must have descriptions'
27
+ include_examples "inputs must have descriptions"
28
28
 
29
- describe 'arguments' do
29
+ describe "arguments" do
30
30
  subject { command.arguments }
31
- it 'has the correct argument order' do
31
+ it "has the correct argument order" do
32
32
  should eq([{:type => :optional, :value => nil, :name => :name}])
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
- describe '#sync_app' do
38
- let(:app) { fake(:app) }
37
+ describe "#sync_app" do
38
+ let(:app) { build(:app, :client => client, :name => "app-name-1") }
39
39
 
40
40
  before do
41
41
  app.stub(:upload)
@@ -47,8 +47,8 @@ module CF
47
47
  push.sync_app(app, path)
48
48
  end
49
49
 
50
- shared_examples 'common tests for inputs' do |*args|
51
- context 'when the new input is the same as the old' do
50
+ shared_examples "common tests for inputs" do |*args|
51
+ context "when the new input is the same as the old" do
52
52
  type, input = args
53
53
  input ||= type
54
54
 
@@ -67,15 +67,15 @@ module CF
67
67
  subject
68
68
  end
69
69
 
70
- it 'uploads the app' do
70
+ it "uploads the app" do
71
71
  app.should_receive(:upload).with(path)
72
72
  subject
73
73
  end
74
74
 
75
- context 'when no inputs are given' do
75
+ context "when no inputs are given" do
76
76
  let(:inputs) { {} }
77
77
 
78
- it 'should not update the app' do
78
+ it "should not update the app" do
79
79
  app.should_not_receive(:update!)
80
80
  subject
81
81
  end
@@ -86,90 +86,93 @@ module CF
86
86
  end
87
87
  end
88
88
 
89
- context 'when memory is given' do
89
+ context "when memory is given" do
90
90
  let(:old) { 1024 }
91
91
  let(:new) { "2G" }
92
- let(:app) { fake(:app, :memory => old) }
92
+ let(:app) { build(:app, :memory => old) }
93
93
  let(:inputs) { {:memory => new} }
94
94
 
95
- it 'updates the app memory, converting to megabytes' do
95
+ it "updates the app memory, converting to megabytes" do
96
96
  push.stub(:line)
97
97
  app.should_receive(:update!)
98
98
  expect { subject }.to change { app.memory }.from(old).to(2048)
99
99
  end
100
100
 
101
- it 'outputs the changed memory in human readable sizes' do
101
+ it "outputs the changed memory in human readable sizes" do
102
102
  push.should_receive(:line).with("Changes:")
103
103
  push.should_receive(:line).with("memory: 1G -> 2G")
104
104
  app.stub(:update!)
105
105
  subject
106
106
  end
107
107
 
108
- include_examples 'common tests for inputs', :memory
108
+ include_examples "common tests for inputs", :memory
109
109
  end
110
110
 
111
- context 'when instances is given' do
111
+ context "when instances is given" do
112
112
  let(:old) { 1 }
113
113
  let(:new) { 2 }
114
- let(:app) { fake(:app, :total_instances => old) }
114
+ let(:app) { build(:app, :total_instances => old) }
115
115
  let(:inputs) { {:instances => new} }
116
116
 
117
- it 'updates the app instances' do
117
+ it "updates the app instances" do
118
118
  push.stub(:line)
119
119
  app.stub(:update!)
120
120
  expect { subject }.to change { app.total_instances }.from(old).to(new)
121
121
  end
122
122
 
123
- it 'outputs the changed instances' do
123
+ it "outputs the changed instances" do
124
124
  push.should_receive(:line).with("Changes:")
125
125
  push.should_receive(:line).with("total_instances: 1 -> 2")
126
126
  app.stub(:update!)
127
127
  subject
128
128
  end
129
129
 
130
- include_examples 'common tests for inputs', :total_instances, :instances
130
+ include_examples "common tests for inputs", :total_instances, :instances
131
131
  end
132
132
 
133
- context 'when command is given' do
133
+ context "when command is given" do
134
134
  let(:old) { "./start" }
135
135
  let(:new) { "./start foo " }
136
- let(:app) { fake(:app, :command => old) }
136
+ let(:app) { build(:app, :command => old) }
137
137
  let(:inputs) { {:command => new} }
138
138
 
139
- it 'updates the app command' do
139
+ it "updates the app command" do
140
140
  push.stub(:line)
141
141
  app.should_receive(:update!)
142
142
  expect { subject }.to change { app.command }.from("./start").to("./start foo ")
143
143
  end
144
144
 
145
- it 'outputs the changed command in single quotes' do
145
+ it "outputs the changed command in single quotes" do
146
146
  push.should_receive(:line).with("Changes:")
147
147
  push.should_receive(:line).with("command: './start' -> './start foo '")
148
148
  app.stub(:update!)
149
149
  subject
150
150
  end
151
151
 
152
- include_examples 'common tests for inputs', :command
152
+ include_examples "common tests for inputs", :command
153
153
  end
154
154
 
155
- context 'when restart is given' do
155
+ context "when restart is given" do
156
156
  let(:inputs) { {:restart => true, :memory => 4096} }
157
157
 
158
+ before do
159
+ CF::App::Base.any_instance.stub(:human_mb).and_return(0)
160
+ end
158
161
 
159
- context 'when the app is already started' do
160
- let(:app) { fake(:app, :state => "STARTED") }
162
+ context "when the app is already started" do
163
+ let(:app) { build(:app, :state => "STARTED") }
161
164
 
162
- it 'invokes the restart command' do
165
+ it "invokes the restart command" do
163
166
  push.stub(:line)
164
167
  app.should_receive(:update!)
165
168
  push.should_receive(:invoke).with(:restart, :app => app)
166
169
  subject
167
170
  end
168
171
 
169
- context 'but there are no changes' do
172
+ context "but there are no changes" do
170
173
  let(:inputs) { {:restart => true} }
171
174
 
172
- it 'invokes the restart command' do
175
+ it "invokes the restart command" do
173
176
  push.stub(:line)
174
177
  app.should_not_receive(:update!)
175
178
  push.should_receive(:invoke).with(:restart, :app => app)
@@ -178,10 +181,10 @@ module CF
178
181
  end
179
182
  end
180
183
 
181
- context 'when the app is not already started' do
182
- let(:app) { fake(:app, :state => "STOPPED") }
184
+ context "when the app is not already started" do
185
+ let(:app) { build(:app, :state => "STOPPED") }
183
186
 
184
- it 'does not invoke the restart command' do
187
+ it "does not invoke the restart command" do
185
188
  push.stub(:line)
186
189
  app.should_receive(:update!)
187
190
  push.should_not_receive(:invoke).with(:restart, :app => app)
@@ -192,7 +195,7 @@ module CF
192
195
 
193
196
  context "when buildpack is given" do
194
197
  let(:old) { nil }
195
- let(:app) { fake(:app, :buildpack => old) }
198
+ let(:app) { build(:app, :buildpack => old) }
196
199
  let(:inputs) { {:buildpack => new} }
197
200
 
198
201
  context "and it's an invalid URL" do
@@ -229,15 +232,15 @@ module CF
229
232
  subject
230
233
  end
231
234
 
232
- include_examples 'common tests for inputs', :buildpack
235
+ include_examples "common tests for inputs", :buildpack
233
236
  end
234
237
  end
235
238
  end
236
239
 
237
- describe '#setup_new_app (integration spec!!)' do
238
- let(:app) { fake(:app, :guid => nil) }
240
+ describe "#setup_new_app (integration spec!!)" do
241
+ let(:app) { build(:app) }
239
242
  let(:host) { "" }
240
- let(:domain) { fake(:domain, :name => "example.com") }
243
+ let(:domain) { build(:domain) }
241
244
  let(:inputs) do
242
245
  {:name => "some-app",
243
246
  :instances => 2,
@@ -257,7 +260,7 @@ module CF
257
260
  push.setup_new_app(path)
258
261
  end
259
262
 
260
- it 'creates the app' do
263
+ it "creates the app" do
261
264
  app.should_receive(:create!)
262
265
  app.should_receive(:upload).with(path)
263
266
  push.should_receive(:filter).with(:create_app, app) { app }