cf 1.1.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -4,7 +4,7 @@ describe CF::App::Rename do
4
4
  let(:global) { { :color => false, :quiet => true } }
5
5
  let(:inputs) { {} }
6
6
  let(:given) { {} }
7
- let(:client) { fake_client }
7
+ let(:client) { build(:client) }
8
8
  let(:app) {}
9
9
  let(:new_name) { "some-new-name" }
10
10
 
@@ -38,6 +38,10 @@ describe CF::App::Rename do
38
38
  end
39
39
 
40
40
  context "when there are no apps" do
41
+ before do
42
+ client.stub(:apps).and_return([])
43
+ end
44
+
41
45
  context "and an app is given" do
42
46
  let(:given) { { :app => "some-app" } }
43
47
  it { expect { subject }.to raise_error(CF::UserError, "Unknown app 'some-app'.") }
@@ -49,14 +53,17 @@ describe CF::App::Rename do
49
53
  end
50
54
 
51
55
  context "when there are apps" do
52
- let(:client) { fake_client(:apps => apps) }
53
- let(:apps) { fake_list(:app, 2) }
56
+ let(:apps) { [build(:app, :client => client), build(:app, :client => client)] }
54
57
  let(:renamed_app) { apps.first }
55
58
 
59
+ before do
60
+ client.stub(:apps).and_return(apps)
61
+ end
62
+
56
63
  context "when the defaults are used" do
57
64
  it "asks for the app and new name and renames" do
58
- mock_ask("Rename which application?", anything) { renamed_app }
59
- mock_ask("New name") { new_name }
65
+ should_ask("Rename which application?", anything) { renamed_app }
66
+ should_ask("New name") { new_name }
60
67
  renamed_app.should_receive(:name=).with(new_name)
61
68
  renamed_app.should_receive(:update!)
62
69
  subject
@@ -68,7 +75,7 @@ describe CF::App::Rename do
68
75
 
69
76
  it "asks for the new name and renames" do
70
77
  dont_allow_ask("Rename which application?", anything)
71
- mock_ask("New name") { new_name }
78
+ should_ask("New name") { new_name }
72
79
  renamed_app.should_receive(:name=).with(new_name)
73
80
  renamed_app.should_receive(:update!)
74
81
  subject
@@ -7,11 +7,16 @@ module CF
7
7
  stub_client_and_precondition
8
8
  end
9
9
 
10
- let(:client) { fake_client :apps => [app] }
10
+ let(:client) { build(:client) }
11
+ let(:app) { }
12
+
13
+ before do
14
+ client.stub(:apps).and_return([app])
15
+ end
11
16
 
12
17
  context "when the --disk flag is given" do
13
18
  let(:before_value) { 512 }
14
- let(:app) { fake :app, :disk_quota => before_value }
19
+ let(:app) { build(:app, :disk_quota => before_value) }
15
20
 
16
21
  subject { cf %W[scale #{app.name} --disk 1G] }
17
22
 
@@ -23,7 +28,7 @@ module CF
23
28
 
24
29
  context "when the --memory flag is given" do
25
30
  let(:before_value) { 512 }
26
- let(:app) { fake :app, :memory => before_value }
31
+ let(:app) { build(:app, :memory => before_value) }
27
32
 
28
33
  subject { cf %W[scale #{app.name} --memory 1G] }
29
34
 
@@ -44,7 +49,7 @@ module CF
44
49
 
45
50
  context "when the --instances flag is given" do
46
51
  let(:before_value) { 3 }
47
- let(:app) { fake :app, :total_instances => before_value }
52
+ let(:app) { build(:app, :total_instances => before_value) }
48
53
 
49
54
  subject { cf %W[scale #{app.name} --instances 5] }
50
55
 
@@ -3,25 +3,28 @@ require "spec_helper"
3
3
  module CF
4
4
  module App
5
5
  describe Start do
6
+ let(:client) { build(:client) }
7
+ let(:app) { build(:app, :client => client, :name => "app-name", :guid => "app-id-1") }
8
+
6
9
  before do
7
10
  stub_client_and_precondition
11
+ client.stub(:apps).and_return([app])
8
12
  end
9
13
 
10
- let(:client) { fake_client :apps => [app] }
11
- let(:app) { fake :app }
12
-
13
- subject { cf %W[start #{app.name}] }
14
+ def execute_start_app
15
+ cf %W[start #{app.name}]
16
+ end
14
17
 
15
18
  context "with an app that's already started" do
16
- let(:app) { fake :app, :state => "STARTED" }
19
+ let(:app) { build(:app, :state => "STARTED") }
17
20
 
18
21
  it "skips starting the application" do
19
22
  app.should_not_receive(:start!)
20
- subject
23
+ execute_start_app
21
24
  end
22
25
 
23
26
  it "says the app is already started" do
24
- subject
27
+ execute_start_app
25
28
  expect(error_output).to say("Application #{app.name} is already started.")
26
29
  end
27
30
  end
@@ -29,28 +32,28 @@ module CF
29
32
  context "with an app that's NOT already started" do
30
33
  def self.it_says_application_is_starting
31
34
  it "says that it's starting the application" do
32
- subject
35
+ execute_start_app
33
36
  expect(output).to say("Starting #{app.name}... OK")
34
37
  end
35
38
  end
36
39
 
37
40
  def self.it_prints_log_progress
38
41
  it "prints out the log progress" do
39
- subject
42
+ execute_start_app
40
43
  expect(output).to say(log_text)
41
44
  end
42
45
  end
43
46
 
44
47
  def self.it_does_not_print_log_progress
45
48
  it "does not print the log progress" do
46
- subject
49
+ execute_start_app
47
50
  expect(output).to_not say(log_text)
48
51
  end
49
52
  end
50
53
 
51
54
  def self.it_waits_for_application_to_become_healthy
52
55
  describe "waits for application to become healthy" do
53
- let(:app) { fake :app, :total_instances => 2 }
56
+ let(:app) { build(:app, :total_instances => 2) }
54
57
 
55
58
  def after_sleep
56
59
  described_class.any_instance.stub(:sleep) { yield }
@@ -76,7 +79,7 @@ module CF
76
79
  end
77
80
 
78
81
  it "says app is started" do
79
- subject
82
+ execute_start_app
80
83
  expect(output).to say("Checking #{app.name}...")
81
84
  expect(output).to say("1 running, 1 down")
82
85
  expect(output).to say("2 running")
@@ -89,7 +92,7 @@ module CF
89
92
  end
90
93
 
91
94
  it "says the app failed to stage" do
92
- subject
95
+ execute_start_app
93
96
  expect(output).to say("Checking #{app.name}...")
94
97
  expect(error_output).to say("Application failed to stage")
95
98
  expect(output).to_not say(/\d (running|down|flapping)/)
@@ -108,7 +111,7 @@ module CF
108
111
  end
109
112
 
110
113
  it "keeps polling" do
111
- subject
114
+ execute_start_app
112
115
  expect(output).to say("Checking #{app.name}...")
113
116
  expect(output).to say("Staging in progress...")
114
117
  expect(output).to say("2 running")
@@ -123,7 +126,7 @@ module CF
123
126
  end
124
127
 
125
128
  it "says app failed to start" do
126
- subject
129
+ execute_start_app
127
130
  expect(output).to say("Checking #{app.name}...")
128
131
  expect(output).to say("1 running, 1 down")
129
132
  expect(output).to say("1 starting, 1 flapping")
@@ -203,31 +206,33 @@ module CF
203
206
  end
204
207
 
205
208
  context "when a debug mode is given" do
206
- let(:mode) { "foo" }
209
+ let(:mode) { "some_mode" }
207
210
 
208
- subject { cf %W[start #{app.name} -d #{mode}] }
211
+ def execute_start_app_with_mode
212
+ cf %W[start #{app.name} -d #{mode}]
213
+ end
209
214
 
210
215
  context "and the debug mode is different from the one already set" do
211
216
  it "starts the app with the given debug mode" do
212
- expect { subject }.to change { app.debug }.from(nil).to("foo")
217
+ expect { execute_start_app_with_mode }.to change { app.debug }.from(nil).to("some_mode")
213
218
  end
214
219
  end
215
220
 
216
221
  context "and the debug mode is the same as the one already set" do
217
- let(:app) { fake :app, :debug => "foo" }
222
+ let(:app) { build(:app, :debug => "in_debug") }
218
223
 
219
224
  it "does not set the debug mode to anything different" do
220
225
  app.should_not_receive(:debug).with(anything)
221
- subject
226
+ execute_start_app_with_mode
222
227
  end
223
228
  end
224
229
 
225
230
  context "and the mode is given as 'none'" do
226
- let(:app) { fake :app, :debug => "foo" }
231
+ let(:app) { build(:app, :debug => "in_debug") }
227
232
  let(:mode) { "none" }
228
233
 
229
234
  it "removes the debug mode" do
230
- expect { subject }.to change { app.debug }.from("foo").to(nil)
235
+ expect { execute_start_app_with_mode }.to change { app.debug }.from("in_debug").to(nil)
231
236
  end
232
237
  end
233
238
 
@@ -235,7 +240,7 @@ module CF
235
240
  let(:mode) { "" }
236
241
 
237
242
  it "sets debug to 'run'" do
238
- expect { subject }.to change { app.debug }.from(nil).to("run")
243
+ expect { execute_start_app_with_mode }.to change { app.debug }.from(nil).to("run")
239
244
  end
240
245
  end
241
246
  end
@@ -3,11 +3,10 @@ require "spec_helper"
3
3
  module CF
4
4
  module App
5
5
  describe Stats do
6
- let(:global) { {:color => false} }
7
- let(:inputs) { {:app => apps[0]} }
6
+ let(:global) { {} }
8
7
  let(:given) { {} }
9
- let(:client) { fake_client(:apps => apps) }
10
- let(:apps) { [fake(:app, :name => "basic_app")] }
8
+ let(:inputs) { {:app => apps[0]} }
9
+ let(:apps) { [build(:app)] }
11
10
 
12
11
  before do
13
12
  inputs[:app].stub(:stats) do
@@ -38,26 +37,26 @@ module CF
38
37
  capture_output { Mothership.new.invoke(:stats, inputs, given, global) }
39
38
  end
40
39
 
41
- describe 'metadata' do
40
+ describe "metadata" do
42
41
  let(:command) { Mothership.commands[:stats] }
43
42
 
44
- describe 'command' do
43
+ describe "command" do
45
44
  subject { command }
46
45
  its(:description) { should eq "Display application instance status" }
47
46
  it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
48
47
  end
49
48
 
50
- include_examples 'inputs must have descriptions'
49
+ include_examples "inputs must have descriptions"
51
50
 
52
- describe 'arguments' do
51
+ describe "arguments" do
53
52
  subject { command.arguments }
54
- it 'has no arguments' do
53
+ it "has no arguments" do
55
54
  should eq([:name => :app, :type => :optional, :value => nil])
56
55
  end
57
56
  end
58
57
  end
59
58
 
60
- it 'prints out the stats' do
59
+ it "prints out the stats" do
61
60
  subject
62
61
  stdout.rewind
63
62
  expect(stdout.readlines.last).to match /.*0\s+0\.0%\s+29\.9M of 288M\s+14\.9M of 256M.*/
@@ -8,17 +8,18 @@ module CF
8
8
  end
9
9
 
10
10
  let(:client) do
11
- fake_client(
12
- :current_organization => organization,
13
- :current_space => space,
14
- :spaces => [space],
15
- :organizations => [organization],
16
- :domains => domains)
11
+ build(:client).tap do |client|
12
+ client.stub(
13
+ :current_organization => organization,
14
+ :current_space => space,
15
+ :spaces => [space],
16
+ :organizations => [organization],
17
+ :domains => domains)
18
+ end
17
19
  end
18
-
19
- let(:organization) { fake(:organization) }
20
- let(:space) { fake(:space, :organization => organization) }
21
- let(:domain) { fake(:domain, :name => domain_name) }
20
+ let(:organization) { build(:organization) }
21
+ let(:space) { build(:space, :organization => organization) }
22
+ let(:domain) { build(:domain, :name => domain_name) }
22
23
  let(:domain_name) { "some.domain.com" }
23
24
  let(:domains) { [domain] }
24
25
 
@@ -76,6 +77,7 @@ module CF
76
77
 
77
78
  context "when a domain and a space are passed" do
78
79
  subject { cf %W[map-domain #{domain.name} --space #{space.name}] }
80
+ before { organization.stub(:spaces).and_return([space]) }
79
81
 
80
82
  include_examples "mapping a domain to a space"
81
83
  end
@@ -123,6 +125,7 @@ module CF
123
125
 
124
126
  context "when a domain, organization, and space is passed" do
125
127
  subject { cf %W[map-domain #{domain.name} --space #{space.name} --organization #{organization.name}] }
128
+ before { organization.stub(:spaces).and_return([space]) }
126
129
 
127
130
  include_examples "mapping a domain to a space"
128
131
  end
@@ -8,23 +8,23 @@ module CF
8
8
  end
9
9
 
10
10
  let(:client) do
11
- fake_client(
12
- :current_organization => organization,
13
- :current_space => space,
14
- :spaces => [space],
15
- :organizations => [organization],
16
- :domains => [domain])
11
+ build(:client).tap do |client|
12
+ client.stub(
13
+ :current_space => space,
14
+ :spaces => [space],
15
+ :organizations => [organization],
16
+ :domains => [domain])
17
+ end
17
18
  end
18
-
19
- let(:organization) { fake(:organization, :spaces => [space]) }
20
- let(:space) { fake(:space) }
21
- let(:domain) { fake(:domain, :name => "some.domain.com") }
19
+ let(:organization) { build(:organization) }
20
+ let(:space) { build(:space, :organization => organization) }
21
+ let(:domain) { build(:domain, :name => "some.domain.com") }
22
22
 
23
23
  context "when the --delete flag is given" do
24
24
  subject { cf %W[unmap-domain #{domain.name} --delete] }
25
25
 
26
26
  it "asks for a confirmation" do
27
- mock_ask("Really delete #{domain.name}?", :default => false) { false }
27
+ should_ask("Really delete #{domain.name}?", :default => false) { false }
28
28
  domain.stub(:delete!)
29
29
  subject
30
30
  end
@@ -15,10 +15,10 @@ module CF
15
15
  end
16
16
 
17
17
  describe "running the command" do
18
- let(:organization) { fake(:organization, :name => "MyOrg") }
18
+ let(:organization) { build(:organization, :name => "MyOrg") }
19
19
  let(:organizations) { [organization] }
20
20
 
21
- let(:client) { fake_client(:current_organization => organization, :organizations => organizations) }
21
+ let(:client) { build(:client) }
22
22
 
23
23
  subject { capture_output { cf %W[delete-org MyOrg --quiet --force] } }
24
24
 
@@ -28,6 +28,7 @@ module CF
28
28
  described_class.any_instance.stub(:check_target)
29
29
  CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
30
30
  organization.stub(:delete!).and_return(true)
31
+ client.stub(:organizations).and_return(organizations)
31
32
  end
32
33
 
33
34
  context "without the force parameter" do
@@ -35,7 +36,7 @@ module CF
35
36
 
36
37
  it "confirms deletion of the organization and deletes it" do
37
38
  organization.should_receive(:delete!).with(:recursive => false) { true }
38
- mock_ask("Really delete #{organization.name}?", {:default => false}) { true }
39
+ should_ask("Really delete #{organization.name}?", {:default => false}) { true }
39
40
 
40
41
  subject
41
42
  end
@@ -49,7 +50,12 @@ module CF
49
50
  end
50
51
 
51
52
  context "when deleting the current organization" do
52
- let(:organizations) { [organization, fake(:organization)] }
53
+ let(:organizations) { [organization, build(:organization)] }
54
+
55
+ before do
56
+ client.stub(:current_organization).and_return(organization)
57
+ end
58
+
53
59
  it "invalidates the old target / client" do
54
60
  described_class.any_instance.should_receive(:invalidate_client)
55
61
  subject
@@ -8,15 +8,19 @@ module CF
8
8
  let(:given) { {} }
9
9
  let(:output) { StringIO.new }
10
10
 
11
- let(:client) { fake_client(:organizations => organizations) }
12
- let!(:org_1) { fake(:organization, :name => "bb_second", :spaces => fake_list(:space, 2), :domains => [fake(:domain)]) }
13
- let!(:org_2) { fake(:organization, :name => "aa_first", :spaces => [fake(:space)], :domains => fake_list(:domain, 3)) }
14
- let!(:org_3) { fake(:organization, :name => "cc_last", :spaces => fake_list(:space, 2), :domains => fake_list(:domain, 2)) }
11
+ let(:client) { build(:client) }
12
+ let(:space) { build(:space) }
13
+ let(:domain) { build(:domain) }
14
+ let!(:org_1) { build(:organization, :name => "bb_second", :spaces => [space], :domains => [domain]) }
15
+ let!(:org_2) { build(:organization, :name => "aa_first", :spaces => [space], :domains => [domain]) }
16
+ let!(:org_3) { build(:organization, :name => "cc_last", :spaces => [space], :domains => [domain]) }
15
17
  let(:organizations) { [org_1, org_2, org_3] }
16
18
 
17
19
  before do
18
20
  CF::CLI.any_instance.stub(:client) { client }
19
21
  CF::CLI.any_instance.stub(:precondition) { nil }
22
+
23
+ client.stub(:organizations).and_return(organizations)
20
24
  end
21
25
 
22
26
  subject do
@@ -85,6 +89,13 @@ module CF
85
89
  end
86
90
 
87
91
  context "and the full flag is not given (default is false)" do
92
+
93
+ before do
94
+ org_1.stub(:spaces).and_return([space])
95
+ org_2.stub(:spaces).and_return([space])
96
+ org_3.stub(:spaces).and_return([space])
97
+ end
98
+
88
99
  it "displays tabular output with names, spaces and domains" do
89
100
  subject
90
101