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,75 @@
1
+ require "spec_helper"
2
+ require "webmock/rspec"
3
+
4
+ command CF::App::Scale do
5
+ let(:client) { fake_client :apps => [app] }
6
+
7
+ context "when the --disk flag is given" do
8
+ let(:before_value) { 512 }
9
+ let(:app) { fake :app, :disk_quota => before_value }
10
+
11
+ subject { cf %W[scale #{app.name} --disk 1G] }
12
+
13
+ it "changes the application's disk quota" do
14
+ mock(app).update!
15
+ expect { subject }.to change(app, :disk_quota).from(before_value).to(1024)
16
+ end
17
+ end
18
+
19
+ context "when the --memory flag is given" do
20
+ let(:before_value) { 512 }
21
+ let(:app) { fake :app, :memory => before_value }
22
+
23
+ subject { cf %W[scale #{app.name} --memory 1G] }
24
+
25
+ it "changes the application's memory" do
26
+ mock(app).update!
27
+ expect { subject }.to change(app, :memory).from(before_value).to(1024)
28
+ end
29
+
30
+ context "if --restart is true" do
31
+ it "restarts the application" do
32
+ stub(app).update!
33
+ stub(app).started? { true }
34
+ mock_invoke :restart, :app => app
35
+ subject
36
+ end
37
+ end
38
+ end
39
+
40
+ context "when the --instances flag is given" do
41
+ let(:before_value) { 3 }
42
+ let(:app) { fake :app, :total_instances => before_value }
43
+
44
+ subject { cf %W[scale #{app.name} --instances 5] }
45
+
46
+ it "changes the application's number of instances" do
47
+ mock(app).update!
48
+ expect { subject }.to change(app, :total_instances).from(before_value).to(5)
49
+ end
50
+ end
51
+
52
+ context "when the --plan flag is given" do
53
+ context "when the plan name begins with a 'p'" do
54
+ let(:app) { fake :app, :production => false }
55
+
56
+ subject { cf %W[scale #{app.name} --plan P100] }
57
+
58
+ it "changes the application's 'production' flag to true" do
59
+ mock(app).update!
60
+ expect { subject }.to change(app, :production).from(false).to(true)
61
+ end
62
+ end
63
+
64
+ context "when the plan name does not begin with a 'p'" do
65
+ let(:app) { fake :app, :production => true }
66
+
67
+ subject { cf %W[scale #{app.name} --plan D100] }
68
+
69
+ it "changes the application's 'production' flag to false" do
70
+ mock(app).update!
71
+ expect { subject }.to change(app, :production).from(true).to(false)
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,208 @@
1
+ require "spec_helper"
2
+ require "webmock/rspec"
3
+
4
+ command CF::App::Start do
5
+ let(:client) { fake_client :apps => [app] }
6
+ let(:app) { fake :app }
7
+
8
+ subject { cf %W[start #{app.name}] }
9
+
10
+ context "with an app that's already started" do
11
+ let(:app) { fake :app, :state => "STARTED" }
12
+
13
+ it "skips starting the application" do
14
+ dont_allow(app).start!
15
+ subject
16
+ end
17
+
18
+ it "says the app is already started" do
19
+ subject
20
+ expect(error_output).to say("Application #{app.name} is already started.")
21
+ end
22
+ end
23
+
24
+ context "with an app that's NOT already started" do
25
+ def self.it_says_application_is_starting
26
+ it "says that it's starting the application" do
27
+ subject
28
+ expect(output).to say("Starting #{app.name}... OK")
29
+ end
30
+ end
31
+
32
+ def self.it_prints_log_progress
33
+ it "prints out the log progress" do
34
+ subject
35
+ expect(output).to say(log_text)
36
+ end
37
+ end
38
+
39
+ def self.it_does_not_print_log_progress
40
+ it "does not print the log progress" do
41
+ subject
42
+ expect(output).to_not say(log_text)
43
+ end
44
+ end
45
+
46
+ def self.it_waits_for_application_to_become_healthy
47
+ describe "waits for application to become healthy" do
48
+ let(:app) { fake :app, :total_instances => 2 }
49
+
50
+ def after_sleep
51
+ any_instance_of described_class do |cli|
52
+ stub(cli).sleep { yield }
53
+ end
54
+ end
55
+
56
+ before do
57
+ stub(app).instances do
58
+ [ CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "DOWN"),
59
+ CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING")
60
+ ]
61
+ end
62
+
63
+ after_sleep do
64
+ stub(app).instances { final_instances }
65
+ end
66
+ end
67
+
68
+ context "when all instances become running" do
69
+ let(:final_instances) do
70
+ [ CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING"),
71
+ CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING")
72
+ ]
73
+ end
74
+
75
+ it "says app is started" do
76
+ subject
77
+ expect(output).to say("Checking #{app.name}...")
78
+ expect(output).to say("1 running, 1 down")
79
+ expect(output).to say("2 running")
80
+ end
81
+ end
82
+
83
+ context "when any instance becomes flapping" do
84
+ let(:final_instances) do
85
+ [ CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "FLAPPING"),
86
+ CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "STARTING")
87
+ ]
88
+ end
89
+
90
+ it "says app failed to start" do
91
+ subject
92
+ expect(output).to say("Checking #{app.name}...")
93
+ expect(output).to say("1 running, 1 down")
94
+ expect(output).to say("1 starting, 1 flapping")
95
+ expect(error_output).to say("Application failed to start")
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ let(:log_url) { nil }
102
+
103
+ before do
104
+ stub(app).invalidate!
105
+ stub(app).instances do
106
+ [ CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING") ]
107
+ end
108
+
109
+ stub(app).start!(true) do |_, blk|
110
+ app.state = "STARTED"
111
+ blk.call(log_url)
112
+ end
113
+ end
114
+
115
+ context "when progress log url is provided" do
116
+ let(:log_url) { "http://example.com/my-app-log" }
117
+ let(:log_text) { "Staging complete!" }
118
+
119
+ context "and progress log url is not available immediately" do
120
+ before do
121
+ stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
122
+ :status => 404, :body => "")
123
+ end
124
+
125
+ it_says_application_is_starting
126
+ it_does_not_print_log_progress
127
+ it_waits_for_application_to_become_healthy
128
+ end
129
+
130
+ context "and progress log url becomes unavailable after some time" do
131
+ before do
132
+ stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
133
+ :status => 200, :body => log_text[0...5])
134
+ stub_request(:get, "#{log_url}&tail&tail_offset=5").to_return(
135
+ :status => 200, :body => log_text[5..-1])
136
+ stub_request(:get, "#{log_url}&tail&tail_offset=#{log_text.size}").to_return(
137
+ :status => 404, :body => "")
138
+ end
139
+
140
+ it_says_application_is_starting
141
+ it_prints_log_progress
142
+ it_waits_for_application_to_become_healthy
143
+ end
144
+
145
+ context "and a request times out" do
146
+ before do
147
+ stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
148
+ :should_timeout => true)
149
+ stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
150
+ :status => 200, :body => log_text)
151
+ stub_request(:get, "#{log_url}&tail&tail_offset=#{log_text.size}").to_return(
152
+ :status => 404, :body => "")
153
+ end
154
+
155
+ it_says_application_is_starting
156
+ it_prints_log_progress
157
+ it_waits_for_application_to_become_healthy
158
+ end
159
+ end
160
+
161
+ context "when progress log url is not provided" do
162
+ let(:log_url) { nil }
163
+ let(:log_text) { "Staging complete!" }
164
+
165
+ it_says_application_is_starting
166
+ it_does_not_print_log_progress
167
+ it_waits_for_application_to_become_healthy
168
+ end
169
+
170
+ context "when a debug mode is given" do
171
+ let(:mode) { "foo" }
172
+
173
+ subject { cf %W[start #{app.name} -d #{mode}] }
174
+
175
+ context "and the debug mode is different from the one already set" do
176
+ it "starts the app with the given debug mode" do
177
+ expect { subject }.to change { app.debug }.from(nil).to("foo")
178
+ end
179
+ end
180
+
181
+ context "and the debug mode is the same as the one already set" do
182
+ let(:app) { fake :app, :debug => "foo" }
183
+
184
+ it "does not set the debug mode to anything different" do
185
+ dont_allow(app).debug = anything
186
+ subject
187
+ end
188
+ end
189
+
190
+ context "and the mode is given as 'none'" do
191
+ let(:app) { fake :app, :debug => "foo" }
192
+ let(:mode) { "none" }
193
+
194
+ it "removes the debug mode" do
195
+ expect { subject }.to change { app.debug }.from("foo").to(nil)
196
+ end
197
+ end
198
+
199
+ context "and an empty mode is given" do
200
+ let(:mode) { "" }
201
+
202
+ it "sets debug to 'run'" do
203
+ expect { subject }.to change { app.debug }.from(nil).to("run")
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe CF::App::Stats do
5
+ let(:global) { { :color => false } }
6
+ let(:inputs) { { :app => apps[0] } }
7
+ let(:given) { {} }
8
+ let(:client) { fake_client(:apps => apps) }
9
+ let(:apps) { [fake(:app, :name => "basic_app")] }
10
+
11
+ before do
12
+ any_instance_of(CF::CLI) do |cli|
13
+ stub(cli).client { client }
14
+ stub(cli).precondition { nil }
15
+ end
16
+ stub(inputs[:app]).stats do
17
+ { "0" => {
18
+ :state => "RUNNING",
19
+ :stats => {
20
+ :name => "basic_app",
21
+ :uris => ["basic_app.p01.rbconsvcs.com"],
22
+ :host => "172.20.183.93",
23
+ :port => 61006,
24
+ :uptime => 3250,
25
+ :mem_quota => 301989888,
26
+ :disk_quota => 268435456,
27
+ :fds_quota => 256,
28
+ :usage => {
29
+ :time => "2013-01-04 19:53:39 +0000",
30
+ :cpu => 0.0019777013519415455,
31
+ :mem => 31395840,
32
+ :disk => 15638528
33
+ }
34
+ }
35
+ }
36
+ }
37
+ end
38
+ end
39
+
40
+ subject do
41
+ capture_output { Mothership.new.invoke(:stats, inputs, given, global) }
42
+ end
43
+
44
+ describe 'metadata' do
45
+ let(:command) { Mothership.commands[:stats] }
46
+
47
+ describe 'command' do
48
+ subject { command }
49
+ its(:description) { should eq "Display application instance status" }
50
+ it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
51
+ end
52
+
53
+ include_examples 'inputs must have descriptions'
54
+
55
+ describe 'arguments' do
56
+ subject { command.arguments }
57
+ it 'has no arguments' do
58
+ should eq([:name=>:app, :type=>:normal, :value=>nil])
59
+ end
60
+ end
61
+ end
62
+
63
+ it 'prints out the stats' do
64
+ subject
65
+ stdout.rewind
66
+ expect(stdout.readlines.last).to match /.*0\s+0\.0%\s+29\.9M of 288M\s+14\.9M of 256M.*/
67
+ end
68
+ end
@@ -0,0 +1,130 @@
1
+ require 'spec_helper'
2
+
3
+ command CF::Domain::Map do
4
+ let(:client) do
5
+ fake_client(
6
+ :current_organization => organization,
7
+ :current_space => space,
8
+ :spaces => [space],
9
+ :organizations => [organization],
10
+ :domains => domains)
11
+ end
12
+
13
+ let(:organization) { fake(:organization) }
14
+ let(:space) { fake(:space, :organization => organization) }
15
+ let(:domain) { fake(:domain, :name => domain_name) }
16
+ let(:domain_name) { "some.domain.com" }
17
+ let(:domains) { [domain] }
18
+
19
+ shared_examples_for "binding a domain to a space" do
20
+ it "adds the domain to the space's organization" do
21
+ mock(space.organization).add_domain(domain)
22
+ stub(space).add_domain(domain)
23
+ subject
24
+ end
25
+
26
+ it 'adds the domain to the space' do
27
+ stub(space.organization).add_domain(domain)
28
+ mock(space).add_domain(domain)
29
+ subject
30
+ end
31
+ end
32
+
33
+ shared_examples_for "binding a domain to an organization" do
34
+ it 'does NOT add the domain to a space' do
35
+ any_instance_of(space.class) do |space|
36
+ dont_allow(space).add_domain(domain)
37
+ end
38
+ end
39
+
40
+ it 'adds the domain to the organization' do
41
+ mock(organization).add_domain(domain)
42
+ subject
43
+ end
44
+ end
45
+
46
+ shared_examples_for "mapping a domain to a space" do
47
+ context "when the domain does NOT exist" do
48
+ let(:domains) { [] }
49
+
50
+ before do
51
+ stub(client).domain { domain }
52
+ stub(domain).create!
53
+ stub(space.organization).add_domain(domain)
54
+ stub(space).add_domain(domain)
55
+ end
56
+
57
+ it 'creates the domain' do
58
+ mock(domain).create!
59
+ subject
60
+ expect(domain.name).to eq domain_name
61
+ expect(domain.owning_organization).to eq organization
62
+ end
63
+
64
+ include_examples "binding a domain to a space"
65
+ end
66
+
67
+ context "when the domain already exists" do
68
+ include_examples "binding a domain to a space"
69
+ end
70
+ end
71
+
72
+ context 'when a domain and a space are passed' do
73
+ subject { cf %W[map-domain #{domain.name} --space #{space.name}] }
74
+
75
+ include_examples "mapping a domain to a space"
76
+ end
77
+
78
+ context 'when a domain and an organization are passed' do
79
+ subject { cf %W[map-domain #{domain.name} --organization #{organization.name}] }
80
+
81
+ context "and the domain does NOT exist" do
82
+ let(:domains) { [] }
83
+
84
+ before do
85
+ stub(client).domain { domain }
86
+ stub(domain).create!
87
+ stub(organization).add_domain(domain)
88
+ end
89
+
90
+ include_examples "binding a domain to an organization"
91
+
92
+ it 'creates the domain' do
93
+ mock(domain).create!
94
+ subject
95
+ expect(domain.name).to eq domain_name
96
+ end
97
+
98
+ context "and the --shared option is passed" do
99
+ subject { cf %W[map-domain #{domain.name} --organization #{organization.name} --shared] }
100
+
101
+ it 'adds the domain to the organization' do
102
+ mock(organization).add_domain(domain)
103
+ subject
104
+ end
105
+
106
+ it "does not add the domain to a specific organization" do
107
+ stub(domain).create!
108
+ subject
109
+ expect(domain.owning_organization).to be_nil
110
+ end
111
+ end
112
+ end
113
+
114
+ context "and the domain already exists" do
115
+ include_examples "binding a domain to an organization"
116
+ end
117
+ end
118
+
119
+ context 'when a domain, organization, and space is passed' do
120
+ subject { cf %W[map-domain #{domain.name} --space #{space.name} --organization #{organization.name}] }
121
+
122
+ include_examples "mapping a domain to a space"
123
+ end
124
+
125
+ context 'when only a domain is passed' do
126
+ subject { cf %W[map-domain #{domain.name}] }
127
+
128
+ include_examples "mapping a domain to a space"
129
+ end
130
+ end