cf 0.1.5 → 0.6.0.rc1

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 (140) hide show
  1. data/LICENSE +1277 -30
  2. data/Rakefile +12 -1
  3. data/bin/cf +0 -3
  4. data/lib/cf.rb +6 -0
  5. data/lib/cf/cli.rb +389 -190
  6. data/lib/cf/cli/app/app.rb +45 -0
  7. data/lib/cf/cli/app/apps.rb +99 -0
  8. data/lib/cf/cli/app/base.rb +90 -0
  9. data/lib/cf/cli/app/crashes.rb +42 -0
  10. data/lib/cf/cli/app/delete.rb +95 -0
  11. data/lib/cf/cli/app/deprecated.rb +11 -0
  12. data/lib/cf/cli/app/env.rb +78 -0
  13. data/lib/cf/cli/app/files.rb +137 -0
  14. data/lib/cf/cli/app/health.rb +26 -0
  15. data/lib/cf/cli/app/instances.rb +53 -0
  16. data/lib/cf/cli/app/logs.rb +76 -0
  17. data/lib/cf/cli/app/push.rb +105 -0
  18. data/lib/cf/cli/app/push/create.rb +149 -0
  19. data/lib/cf/cli/app/push/interactions.rb +94 -0
  20. data/lib/cf/cli/app/push/sync.rb +64 -0
  21. data/lib/cf/cli/app/rename.rb +35 -0
  22. data/lib/cf/cli/app/restart.rb +20 -0
  23. data/lib/cf/cli/app/scale.rb +69 -0
  24. data/lib/cf/cli/app/start.rb +143 -0
  25. data/lib/cf/cli/app/stats.rb +67 -0
  26. data/lib/cf/cli/app/stop.rb +27 -0
  27. data/lib/cf/cli/domain/base.rb +8 -0
  28. data/lib/cf/cli/domain/domains.rb +40 -0
  29. data/lib/cf/cli/domain/map.rb +55 -0
  30. data/lib/cf/cli/domain/unmap.rb +56 -0
  31. data/lib/cf/cli/help.rb +15 -0
  32. data/lib/cf/cli/interactive.rb +105 -0
  33. data/lib/cf/cli/organization/base.rb +12 -0
  34. data/lib/cf/cli/organization/create.rb +32 -0
  35. data/lib/cf/cli/organization/delete.rb +73 -0
  36. data/lib/cf/cli/organization/org.rb +45 -0
  37. data/lib/cf/cli/organization/orgs.rb +35 -0
  38. data/lib/cf/cli/organization/rename.rb +36 -0
  39. data/lib/cf/cli/route/base.rb +8 -0
  40. data/lib/cf/cli/route/map.rb +70 -0
  41. data/lib/cf/cli/route/routes.rb +26 -0
  42. data/lib/cf/cli/route/unmap.rb +62 -0
  43. data/lib/cf/cli/service/base.rb +8 -0
  44. data/lib/cf/cli/service/bind.rb +44 -0
  45. data/lib/cf/cli/service/create.rb +107 -0
  46. data/lib/cf/cli/service/delete.rb +82 -0
  47. data/lib/cf/cli/service/rename.rb +35 -0
  48. data/lib/cf/cli/service/service.rb +40 -0
  49. data/lib/cf/cli/service/services.rb +99 -0
  50. data/lib/cf/cli/service/unbind.rb +38 -0
  51. data/lib/cf/cli/space/base.rb +19 -0
  52. data/lib/cf/cli/space/create.rb +63 -0
  53. data/lib/cf/cli/space/delete.rb +95 -0
  54. data/lib/cf/cli/space/rename.rb +39 -0
  55. data/lib/cf/cli/space/space.rb +64 -0
  56. data/lib/cf/cli/space/spaces.rb +55 -0
  57. data/lib/cf/cli/space/switch.rb +16 -0
  58. data/lib/cf/cli/start/base.rb +93 -0
  59. data/lib/cf/cli/start/colors.rb +13 -0
  60. data/lib/cf/cli/start/info.rb +124 -0
  61. data/lib/cf/cli/start/login.rb +94 -0
  62. data/lib/cf/cli/start/logout.rb +17 -0
  63. data/lib/cf/cli/start/target.rb +69 -0
  64. data/lib/cf/cli/start/target_interactions.rb +37 -0
  65. data/lib/cf/cli/start/targets.rb +16 -0
  66. data/lib/cf/cli/user/base.rb +29 -0
  67. data/lib/cf/cli/user/create.rb +39 -0
  68. data/lib/cf/cli/user/passwd.rb +43 -0
  69. data/lib/cf/cli/user/register.rb +42 -0
  70. data/lib/cf/cli/user/users.rb +32 -0
  71. data/lib/cf/constants.rb +10 -7
  72. data/lib/cf/detect.rb +113 -48
  73. data/lib/cf/errors.rb +17 -0
  74. data/lib/cf/plugin.rb +28 -12
  75. data/lib/cf/spacing.rb +89 -0
  76. data/lib/cf/spec_helper.rb +1 -0
  77. data/lib/cf/test_support.rb +6 -0
  78. data/lib/cf/version.rb +1 -1
  79. data/spec/assets/hello-sinatra/Gemfile +3 -0
  80. data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
  81. data/spec/assets/hello-sinatra/config.ru +3 -0
  82. data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
  83. data/spec/assets/hello-sinatra/main.rb +6 -0
  84. data/spec/assets/specker_runner/specker_runner_input.rb +6 -0
  85. data/spec/assets/specker_runner/specker_runner_pause.rb +5 -0
  86. data/spec/cf/cli/app/base_spec.rb +17 -0
  87. data/spec/cf/cli/app/delete_spec.rb +188 -0
  88. data/spec/cf/cli/app/instances_spec.rb +65 -0
  89. data/spec/cf/cli/app/push/create_spec.rb +661 -0
  90. data/spec/cf/cli/app/push_spec.rb +369 -0
  91. data/spec/cf/cli/app/rename_spec.rb +104 -0
  92. data/spec/cf/cli/app/scale_spec.rb +75 -0
  93. data/spec/cf/cli/app/start_spec.rb +208 -0
  94. data/spec/cf/cli/app/stats_spec.rb +68 -0
  95. data/spec/cf/cli/domain/map_spec.rb +130 -0
  96. data/spec/cf/cli/domain/unmap_spec.rb +69 -0
  97. data/spec/cf/cli/organization/orgs_spec.rb +108 -0
  98. data/spec/cf/cli/organization/rename_spec.rb +113 -0
  99. data/spec/cf/cli/route/map_spec.rb +121 -0
  100. data/spec/cf/cli/route/unmap_spec.rb +155 -0
  101. data/spec/cf/cli/service/bind_spec.rb +25 -0
  102. data/spec/cf/cli/service/delete_spec.rb +22 -0
  103. data/spec/cf/cli/service/rename_spec.rb +105 -0
  104. data/spec/cf/cli/service/service_spec.rb +23 -0
  105. data/spec/cf/cli/service/unbind_spec.rb +25 -0
  106. data/spec/cf/cli/space/create_spec.rb +93 -0
  107. data/spec/cf/cli/space/rename_spec.rb +102 -0
  108. data/spec/cf/cli/space/spaces_spec.rb +104 -0
  109. data/spec/cf/cli/space/switch_space_spec.rb +55 -0
  110. data/spec/cf/cli/start/info_spec.rb +160 -0
  111. data/spec/cf/cli/start/login_spec.rb +142 -0
  112. data/spec/cf/cli/start/logout_spec.rb +50 -0
  113. data/spec/cf/cli/start/target_spec.rb +123 -0
  114. data/spec/cf/cli/user/create_spec.rb +54 -0
  115. data/spec/cf/cli/user/passwd_spec.rb +102 -0
  116. data/spec/cf/cli/user/register_spec.rb +140 -0
  117. data/spec/cf/cli_spec.rb +442 -0
  118. data/spec/cf/detect_spec.rb +54 -0
  119. data/spec/console_app_specker/console_app_specker_matchers_spec.rb +173 -0
  120. data/spec/console_app_specker/specker_runner_spec.rb +167 -0
  121. data/spec/features/account_lifecycle_spec.rb +85 -0
  122. data/spec/features/login_spec.rb +66 -0
  123. data/spec/features/push_flow_spec.rb +125 -0
  124. data/spec/features/switching_targets_spec.rb +32 -0
  125. data/spec/spec_helper.rb +72 -0
  126. data/spec/support/command_helper.rb +81 -0
  127. data/spec/support/config_helper.rb +15 -0
  128. data/spec/support/console_app_specker_matchers.rb +86 -0
  129. data/spec/support/fake_home_dir.rb +55 -0
  130. data/spec/support/interact_helper.rb +29 -0
  131. data/spec/support/shared_examples/errors.rb +40 -0
  132. data/spec/support/shared_examples/input.rb +14 -0
  133. data/spec/support/specker_runner.rb +80 -0
  134. data/spec/support/tracking_expector.rb +71 -0
  135. metadata +427 -66
  136. data/lib/cf/cli/app.rb +0 -595
  137. data/lib/cf/cli/command.rb +0 -444
  138. data/lib/cf/cli/dots.rb +0 -133
  139. data/lib/cf/cli/service.rb +0 -112
  140. data/lib/cf/cli/user.rb +0 -71
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe CF::Service::Bind do
4
+ describe 'metadata' do
5
+ let(:command) { Mothership.commands[:bind_service] }
6
+
7
+ describe 'command' do
8
+ subject { command }
9
+ its(:description) { should eq "Bind a service to an application" }
10
+ it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
11
+ end
12
+
13
+ include_examples 'inputs must have descriptions'
14
+
15
+ describe 'arguments' do
16
+ subject { command.arguments }
17
+ it 'has the correct argument order' do
18
+ should eq([
19
+ { :type => :optional, :value => nil, :name => :service },
20
+ { :type => :optional, :value => nil, :name => :app }
21
+ ])
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe CF::Service::Delete do
4
+ describe 'metadata' do
5
+ let(:command) { Mothership.commands[:delete_service] }
6
+
7
+ describe 'command' do
8
+ subject { command }
9
+ its(:description) { should eq "Delete a service" }
10
+ it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
11
+ end
12
+
13
+ include_examples 'inputs must have descriptions'
14
+
15
+ describe 'arguments' do
16
+ subject { command.arguments }
17
+ it 'has the correct argument order' do
18
+ should eq([{:type => :optional, :value => nil, :name => :service }])
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+ require "cf/cli/service/rename"
3
+
4
+ describe CF::Service::Rename do
5
+ let(:global) { { :color => false, :quiet => true } }
6
+ let(:inputs) { {} }
7
+ let(:given) { {} }
8
+ let(:client) { fake_client }
9
+ let(:service) {}
10
+ let(:new_name) { "some-new-name" }
11
+
12
+ before do
13
+ any_instance_of(CF::CLI) do |cli|
14
+ stub(cli).client { client }
15
+ stub(cli).precondition { nil }
16
+ end
17
+ end
18
+
19
+ subject { Mothership.new.invoke(:rename_service, inputs, given, global) }
20
+
21
+ describe 'metadata' do
22
+ let(:command) { Mothership.commands[:rename_service] }
23
+
24
+ describe 'command' do
25
+ subject { command }
26
+ its(:description) { should eq "Rename a service" }
27
+ it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
28
+ end
29
+
30
+ include_examples 'inputs must have descriptions'
31
+
32
+ describe 'arguments' do
33
+ subject { command.arguments }
34
+ it 'has the correct argument order' do
35
+ should eq([
36
+ { :type => :optional, :value => nil, :name => :service },
37
+ { :type => :optional, :value => nil, :name => :name }
38
+ ])
39
+ end
40
+ end
41
+ end
42
+
43
+ context 'when there are no services' do
44
+ context 'and a service is given' do
45
+ let(:given) { { :service => "some-service" } }
46
+ it { expect { subject }.to raise_error(CF::UserError, "Unknown service 'some-service'.") }
47
+ end
48
+
49
+ context 'and a service is not given' do
50
+ it { expect { subject }.to raise_error(CF::UserError, "No services.") }
51
+ end
52
+ end
53
+
54
+ context 'when there are services' do
55
+ let(:client) { fake_client(:service_instances => services) }
56
+ let(:services) { fake_list(:service_instance, 2) }
57
+ let(:renamed_service) { services.first }
58
+
59
+ context 'when the defaults are used' do
60
+ it 'asks for the service and new name and renames' do
61
+ mock_ask("Rename which service?", anything) { renamed_service }
62
+ mock_ask("New name") { new_name }
63
+ mock(renamed_service).name=(new_name)
64
+ mock(renamed_service).update!
65
+ subject
66
+ end
67
+ end
68
+
69
+ context 'when no name is provided, but a service is' do
70
+ let(:given) { { :service => renamed_service.name } }
71
+
72
+ it 'asks for the new name and renames' do
73
+ dont_allow_ask("Rename which service?", anything)
74
+ mock_ask("New name") { new_name }
75
+ mock(renamed_service).name=(new_name)
76
+ mock(renamed_service).update!
77
+ subject
78
+ end
79
+ end
80
+
81
+ context 'when a service is provided and a name' do
82
+ let(:inputs) { { :service => renamed_service, :name => new_name } }
83
+
84
+ it 'renames the service' do
85
+ mock(renamed_service).update!
86
+ subject
87
+ end
88
+
89
+ it 'displays the progress' do
90
+ mock_with_progress("Renaming to #{new_name}")
91
+ mock(renamed_service).update!
92
+
93
+ subject
94
+ end
95
+
96
+ context 'and the name already exists' do
97
+ it 'fails' do
98
+ mock(renamed_service).update! { raise CFoundry::ServiceInstanceNameTaken.new("Taken", 200) }
99
+ expect { subject }.to raise_error(CFoundry::ServiceInstanceNameTaken)
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe CF::Service::Service do
4
+ describe 'metadata' do
5
+ let(:command) { Mothership.commands[:service] }
6
+
7
+ describe 'command' do
8
+ subject { command }
9
+ its(:description) { should eq "Show service information" }
10
+ it { expect(Mothership::Help.group(:services)).to include(subject) }
11
+ end
12
+
13
+ include_examples 'inputs must have descriptions'
14
+
15
+ describe 'arguments' do
16
+ subject { command.arguments }
17
+ it 'has the correct argument order' do
18
+ should eq([{:type => :required, :value=>nil, :name=>:service}])
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe CF::Service::Unbind do
4
+ describe 'metadata' do
5
+ let(:command) { Mothership.commands[:unbind_service] }
6
+
7
+ describe 'command' do
8
+ subject { command }
9
+ its(:description) { should eq "Unbind a service from an application" }
10
+ it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
11
+ end
12
+
13
+ include_examples 'inputs must have descriptions'
14
+
15
+ describe 'arguments' do
16
+ subject { command.arguments }
17
+ it 'has the correct argument order' do
18
+ should eq([
19
+ { :type => :optional, :value => nil, :name => :service },
20
+ { :type => :optional, :value => nil, :name => :app }
21
+ ])
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+ require "cf/cli/space/create"
3
+
4
+ command CF::Space::Create do
5
+ describe 'metadata' do
6
+ let(:command) { Mothership.commands[:create_space] }
7
+
8
+ describe 'command' do
9
+ subject { command }
10
+ its(:description) { should eq "Create a space in an organization" }
11
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
12
+ end
13
+
14
+ include_examples 'inputs must have descriptions'
15
+
16
+ describe 'arguments' do
17
+ subject { command.arguments }
18
+ it 'has the correct argument order' do
19
+ should eq([
20
+ { :type => :optional, :value => nil, :name => :name },
21
+ { :type => :optional, :value => nil, :name => :organization }
22
+ ])
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "running the command" do
28
+ let(:client) do
29
+ fake_client(:current_organization => organization)
30
+ end
31
+
32
+ let(:organization) { fake(:organization) }
33
+
34
+ let(:new_space) { fake :space, :name => new_name }
35
+ let(:new_name) { "some-new-name" }
36
+
37
+ before do
38
+ stub(client).space { new_space }
39
+ stub(new_space).create!
40
+ stub(new_space).add_manager
41
+ stub(new_space).add_developer
42
+ stub(new_space).add_auditor
43
+ end
44
+
45
+ context "when --target is given" do
46
+ subject { cf %W[create-space #{new_space.name} --target] }
47
+
48
+ it "switches them to the new space" do
49
+ mock_invoke :target, :organization => organization,
50
+ :space => new_space
51
+ subject
52
+ end
53
+ end
54
+
55
+ context "when --target is NOT given" do
56
+ subject { cf %W[create-space #{new_space.name}] }
57
+
58
+ it "tells the user how they can switch to the new space" do
59
+ subject
60
+ expect(output).to say("Space created! Use switch-space #{new_space.name} to target it.")
61
+ end
62
+ end
63
+
64
+ context "when we don't specify an organization" do
65
+ subject { cf %W[create-space #{new_space.name}] }
66
+
67
+ context "when we have a default organization" do
68
+ it "uses that organization to create a space" do
69
+ subject
70
+
71
+ stdout.rewind
72
+ expect(stdout.readline).to include "Creating space"
73
+ end
74
+ end
75
+
76
+ context "when we don't have a default organization" do
77
+ let(:organization) { nil }
78
+
79
+ it "shows the help for the command" do
80
+ subject
81
+
82
+ stdout.rewind
83
+ expect(stdout.readline).to include "Create a space in an organization"
84
+ end
85
+
86
+ it "does not try to create the space" do
87
+ new_space.create! { raise "should not call this method" } # rr not behaving
88
+ subject
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,102 @@
1
+ require 'spec_helper'
2
+ require "cf/cli/space/rename"
3
+
4
+ describe CF::Space::Rename do
5
+ let(:spaces) { fake_list(:space, 3) }
6
+ let(:organization) { fake(:organization, :spaces => spaces) }
7
+ let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
8
+ let(:new_name) { "some-new-name" }
9
+
10
+ before do
11
+ any_instance_of described_class do |cli|
12
+ stub(cli).client { client }
13
+ stub(cli).precondition { nil }
14
+ end
15
+ end
16
+
17
+ describe 'metadata' do
18
+ let(:command) { Mothership.commands[:rename_space] }
19
+
20
+ describe 'command' do
21
+ subject { command }
22
+ its(:description) { should eq "Rename a space" }
23
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
24
+ end
25
+
26
+ include_examples 'inputs must have descriptions'
27
+
28
+ describe 'arguments' do
29
+ subject { command.arguments }
30
+ it 'has the correct argument order' do
31
+ should eq([
32
+ { :type => :optional, :value => nil, :name => :space },
33
+ { :type => :optional, :value => nil, :name => :name }
34
+ ])
35
+ end
36
+ end
37
+ end
38
+
39
+ context 'when there are no spaces' do
40
+ let(:spaces) { [] }
41
+
42
+ context 'and a space is given' do
43
+ subject { cf %W[rename-space --space some-invalid-space --no-force --no-quiet] }
44
+ it 'prints out an error message' do
45
+ subject
46
+ expect(stderr.string).to include "Unknown space 'some-invalid-space'."
47
+ end
48
+ end
49
+
50
+ context 'and a space is not given' do
51
+ subject { cf %W[rename-space --no-force] }
52
+ it 'prints out an error message' do
53
+ subject
54
+ expect(stderr.string).to include "No spaces."
55
+ end
56
+ end
57
+ end
58
+
59
+ context 'when there are spaces' do
60
+ let(:renamed_space) { spaces.first }
61
+
62
+ context 'when the defaults are used' do
63
+ subject { cf %W[rename-space --no-force --no-quiet] }
64
+
65
+ it 'asks for the space and new name and renames' do
66
+ mock_ask("Rename which space?", anything) { renamed_space }
67
+ mock_ask("New name") { new_name }
68
+ mock(renamed_space).name=(new_name)
69
+ mock(renamed_space).update!
70
+ subject
71
+ end
72
+ end
73
+
74
+ context 'when no name is provided, but a space is' do
75
+ subject { cf %W[rename-space --space #{renamed_space.name} --no-force] }
76
+
77
+ it 'asks for the new name and renames' do
78
+ dont_allow_ask("Rename which space?", anything)
79
+ mock_ask("New name") { new_name }
80
+ mock(renamed_space).name=(new_name)
81
+ mock(renamed_space).update!
82
+ subject
83
+ end
84
+ end
85
+
86
+ context 'when a space is provided and a name' do
87
+ subject { cf %W[rename-space --space #{renamed_space.name} --name #{new_name} --no-force] }
88
+
89
+ it 'renames the space' do
90
+ mock(renamed_space).update!
91
+ subject
92
+ end
93
+
94
+ it 'displays the progress' do
95
+ mock_with_progress("Renaming to #{new_name}")
96
+ mock(renamed_space).update!
97
+
98
+ subject
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe CF::Space::Spaces do
5
+ let(:full) { false }
6
+ let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
7
+ let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
8
+ let!(:space_3) { fake(:space, :name => "cc_last", :apps => fake_list(:app, 2), :service_instances => fake_list(:service_instance, 2), :domains => fake_list(:domain, 2)) }
9
+ let(:spaces) { [space_1, space_2, space_3]}
10
+ let(:organization) { fake(:organization, :spaces => spaces) }
11
+ let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
12
+
13
+ before do
14
+ any_instance_of described_class do |cli|
15
+ stub(cli).client { client }
16
+ stub(cli).precondition { nil }
17
+ end
18
+ end
19
+
20
+ describe 'metadata' do
21
+ let(:command) { Mothership.commands[:spaces] }
22
+
23
+ describe 'command' do
24
+ subject { command }
25
+ its(:description) { should eq "List spaces in an organization" }
26
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
27
+ end
28
+
29
+ include_examples 'inputs must have descriptions'
30
+
31
+ describe 'arguments' do
32
+ subject { command.arguments }
33
+ it 'has the correct argument order' do
34
+ should eq([{ :type => :optional, :value => nil, :name => :organization }])
35
+ end
36
+ end
37
+ end
38
+
39
+ subject { cf %W[spaces --#{bool_flag(:full)} --no-quiet] }
40
+
41
+ it 'should have the correct first two lines' do
42
+ subject
43
+
44
+ stdout.rewind
45
+ expect(stdout.readline).to match /Getting spaces.*OK/
46
+ expect(stdout.readline).to eq "\n"
47
+ end
48
+
49
+ context 'when there are no spaces' do
50
+ let(:spaces) { [] }
51
+
52
+ context 'and the full flag is given' do
53
+ let(:full) { true }
54
+
55
+ it 'displays yaml-style output with all space details' do
56
+ any_instance_of CF::Space::Spaces do |spaces|
57
+ dont_allow(spaces).invoke
58
+ end
59
+ subject
60
+ end
61
+ end
62
+
63
+ context 'and the full flag is not given (default is false)' do
64
+ it 'should show only the progress' do
65
+ subject
66
+
67
+ stdout.rewind
68
+ expect(stdout.readline).to match /Getting spaces.*OK/
69
+ expect(stdout).to be_eof
70
+ end
71
+ end
72
+ end
73
+
74
+ context 'when there are spaces' do
75
+ context 'and the full flag is given' do
76
+ let(:full) { true }
77
+
78
+ it 'displays yaml-style output with all space details' do
79
+ any_instance_of CF::Space::Spaces do |spaces|
80
+ mock(spaces).invoke(:space, :space => space_2, :full => true).ordered
81
+ mock(spaces).invoke(:space, :space => space_1, :full => true).ordered
82
+ mock(spaces).invoke(:space, :space => space_3, :full => true).ordered
83
+ end
84
+ subject
85
+ end
86
+ end
87
+
88
+ context 'and the full flag is not given (default is false)' do
89
+ it 'displays tabular output with names, spaces and domains' do
90
+ subject
91
+
92
+ stdout.rewind
93
+ stdout.readline
94
+ stdout.readline
95
+
96
+ expect(stdout.readline).to match /name\s+apps\s+services/
97
+ spaces.sort_by(&:name).each do |space|
98
+ expect(stdout.readline).to match /#{space.name}\s+#{name_list(space.apps)}\s+#{name_list(space.service_instances)}/
99
+ end
100
+ expect(stdout).to be_eof
101
+ end
102
+ end
103
+ end
104
+ end