cf 1.1.3.rc1 → 1.1.4
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.
- data/lib/cf/cli.rb +2 -7
- data/lib/cf/cli/organization/delete.rb +4 -6
- data/lib/cf/cli/service/create.rb +23 -17
- data/lib/cf/cli/space/create.rb +43 -41
- data/lib/cf/cli/space/space.rb +49 -46
- data/lib/cf/version.rb +1 -1
- data/lib/console/console.rb +1 -1
- data/spec/cf/cli/app/delete_spec.rb +16 -28
- data/spec/cf/cli/app/instances_spec.rb +4 -5
- data/spec/cf/cli/app/push/create_spec.rb +362 -373
- data/spec/cf/cli/app/push_spec.rb +216 -215
- data/spec/cf/cli/app/rename_spec.rb +28 -31
- data/spec/cf/cli/app/scale_spec.rb +44 -41
- data/spec/cf/cli/app/start_spec.rb +194 -193
- data/spec/cf/cli/app/stats_spec.rb +55 -56
- data/spec/cf/cli/domain/map_spec.rb +105 -102
- data/spec/cf/cli/domain/unmap_spec.rb +60 -56
- data/spec/cf/cli/organization/delete_spec.rb +85 -84
- data/spec/cf/cli/organization/orgs_spec.rb +80 -83
- data/spec/cf/cli/organization/rename_spec.rb +90 -89
- data/spec/cf/cli/populators/organization_spec.rb +117 -119
- data/spec/cf/cli/populators/space_spec.rb +107 -108
- data/spec/cf/cli/populators/target_spec.rb +17 -12
- data/spec/cf/cli/route/delete_spec.rb +4 -4
- data/spec/cf/cli/route/map_spec.rb +106 -102
- data/spec/cf/cli/route/unmap_spec.rb +5 -5
- data/spec/cf/cli/service/create_spec.rb +74 -46
- data/spec/cf/cli/service/rename_spec.rb +29 -33
- data/spec/cf/cli/service/services_spec.rb +48 -48
- data/spec/cf/cli/space/base_spec.rb +39 -32
- data/spec/cf/cli/space/create_spec.rb +52 -53
- data/spec/cf/cli/space/delete_spec.rb +84 -85
- data/spec/cf/cli/space/rename_spec.rb +93 -94
- data/spec/cf/cli/space/space_spec.rb +60 -60
- data/spec/cf/cli/space/spaces_spec.rb +75 -80
- data/spec/cf/cli/space/switch_space_spec.rb +45 -48
- data/spec/cf/cli/start/info_spec.rb +4 -6
- data/spec/cf/cli/start/login_spec.rb +18 -20
- data/spec/cf/cli/start/logout_spec.rb +36 -37
- data/spec/cf/cli/start/target_spec.rb +86 -89
- data/spec/cf/cli/user/create_spec.rb +83 -84
- data/spec/cf/cli/user/passwd_spec.rb +87 -86
- data/spec/cf/cli/user/register_spec.rb +109 -108
- data/spec/cf/cli_spec.rb +305 -310
- data/spec/console/console_spec.rb +58 -58
- data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
- data/spec/features/org_spec.rb +11 -11
- data/spec/manifests/manifests_spec.rb +21 -21
- data/spec/manifests/plugin_spec.rb +34 -34
- data/spec/spec_helper.rb +1 -2
- data/spec/support/cli_helper.rb +5 -14
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/interact_helper.rb +5 -15
- data/spec/support/shared_examples/errors.rb +1 -1
- data/spec/tunnel/plugin_spec.rb +2 -2
- data/spec/tunnel/tunnel_spec.rb +5 -5
- metadata +36 -28
@@ -1,499 +1,488 @@
|
|
1
|
-
require
|
2
|
-
require 'fakefs/safe'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module CF
|
4
|
+
module App
|
5
|
+
describe Create do
|
6
|
+
let(:inputs) { {} }
|
7
|
+
let(:given) { {} }
|
8
|
+
let(:global) { {:color => false, :quiet => true} }
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
let(:service_instances) { fake_list(:service_instance, 5) }
|
11
|
+
let(:lucid64) { fake :stack, :name => "lucid64" }
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
before do
|
17
|
-
any_instance_of(CF::CLI) do |cli|
|
18
|
-
stub(cli).client { client }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:path) { "some-path" }
|
23
|
-
|
24
|
-
subject(:create) do
|
25
|
-
command = Mothership.commands[:push]
|
26
|
-
create = CF::App::Push.new(command)
|
27
|
-
create.path = path
|
28
|
-
create.input = Mothership::Inputs.new(command, create, inputs, given, global)
|
29
|
-
create.extend CF::App::PushInteractions
|
30
|
-
create
|
31
|
-
end
|
13
|
+
let(:client) do
|
14
|
+
fake_client(:service_instances => service_instances, :stacks => [lucid64])
|
15
|
+
end
|
32
16
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
let(:given) do
|
37
|
-
{ :name => "some-name",
|
38
|
-
:instances => "1",
|
39
|
-
:plan => "100",
|
40
|
-
:memory => "1G",
|
41
|
-
:command => "ruby main.rb",
|
42
|
-
:buildpack => "git://example.com",
|
43
|
-
:stack => "lucid64"
|
44
|
-
}
|
45
|
-
end
|
17
|
+
before do
|
18
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
19
|
+
end
|
46
20
|
|
47
|
-
|
48
|
-
its([:name]) { should eq "some-name" }
|
49
|
-
its([:total_instances]) { should eq 1 }
|
50
|
-
its([:space]) { should eq client.current_space }
|
51
|
-
its([:command]) { should eq "ruby main.rb" }
|
52
|
-
its([:memory]) { should eq 1024 }
|
53
|
-
its([:stack]) { should eq lucid64 }
|
54
|
-
end
|
21
|
+
let(:path) { "some-path" }
|
55
22
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
23
|
+
subject(:create) do
|
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
|
30
|
+
end
|
61
31
|
|
62
|
-
|
63
|
-
|
64
|
-
|
32
|
+
describe "#get_inputs" do
|
33
|
+
subject { create.get_inputs }
|
34
|
+
|
35
|
+
let(:given) do
|
36
|
+
{:name => "some-name",
|
37
|
+
:instances => "1",
|
38
|
+
:plan => "100",
|
39
|
+
:memory => "1G",
|
40
|
+
:command => "ruby main.rb",
|
41
|
+
:buildpack => "git://example.com",
|
42
|
+
:stack => "lucid64"
|
43
|
+
}
|
65
44
|
end
|
66
45
|
|
67
|
-
|
68
|
-
|
69
|
-
|
46
|
+
context "when all the inputs are given" do
|
47
|
+
its([:name]) { should eq "some-name" }
|
48
|
+
its([:total_instances]) { should eq 1 }
|
49
|
+
its([:space]) { should eq client.current_space }
|
50
|
+
its([:command]) { should eq "ruby main.rb" }
|
51
|
+
its([:memory]) { should eq 1024 }
|
52
|
+
its([:stack]) { should eq lucid64 }
|
70
53
|
end
|
71
54
|
|
72
|
-
|
73
|
-
|
74
|
-
|
55
|
+
context "when the command is given" do
|
56
|
+
context "and there is a Procfile in the application's root" do
|
57
|
+
before do
|
58
|
+
FakeFS.activate!
|
59
|
+
Dir.mkdir(path)
|
75
60
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
subject
|
81
|
-
end
|
61
|
+
File.open("#{path}/Procfile", "w") do |file|
|
62
|
+
file.write("this is a procfile")
|
63
|
+
end
|
64
|
+
end
|
82
65
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
66
|
+
after do
|
67
|
+
FakeFS.deactivate!
|
68
|
+
FakeFS::FileSystem.clear
|
69
|
+
end
|
88
70
|
|
89
|
-
|
90
|
-
|
71
|
+
its([:command]) { should eq "ruby main.rb" }
|
72
|
+
end
|
73
|
+
end
|
91
74
|
|
92
|
-
|
93
|
-
it "asks for
|
94
|
-
|
95
|
-
|
96
|
-
|
75
|
+
context "when certain inputs are not given" do
|
76
|
+
it "asks for the name" do
|
77
|
+
given.delete(:name)
|
78
|
+
mock_ask("Name") { "some-name" }
|
79
|
+
subject
|
80
|
+
end
|
97
81
|
|
98
|
-
|
82
|
+
it "asks for the total instances" do
|
83
|
+
given.delete(:instances)
|
84
|
+
mock_ask("Instances", anything) { 1 }
|
85
|
+
subject
|
99
86
|
end
|
100
87
|
|
101
|
-
context "when the
|
102
|
-
|
103
|
-
|
104
|
-
|
88
|
+
context "when the command is not given" do
|
89
|
+
before { given.delete(:command) }
|
90
|
+
|
91
|
+
shared_examples "an app that can have a custom start command" do
|
92
|
+
it "asks for a start command with a default as 'none'" do
|
93
|
+
mock_ask("Custom startup command", :default => "none") do
|
94
|
+
"abcd"
|
95
|
+
end
|
96
|
+
|
97
|
+
expect(subject[:command]).to eq "abcd"
|
105
98
|
end
|
106
99
|
|
107
|
-
|
100
|
+
context "when the user enters 'none'" do
|
101
|
+
it "has the command as nil" do
|
102
|
+
stub_ask("Custom startup command", :default => "none") do
|
103
|
+
"none"
|
104
|
+
end
|
105
|
+
|
106
|
+
expect(subject[:command]).to be_nil
|
107
|
+
end
|
108
|
+
end
|
108
109
|
end
|
109
|
-
end
|
110
|
-
end
|
111
110
|
|
112
|
-
|
111
|
+
include_examples "an app that can have a custom start command"
|
113
112
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
113
|
+
describe "getting the start command" do
|
114
|
+
before do
|
115
|
+
FakeFS.activate!
|
116
|
+
Dir.mkdir(path)
|
117
|
+
end
|
119
118
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
119
|
+
after do
|
120
|
+
FakeFS.deactivate!
|
121
|
+
FakeFS::FileSystem.clear
|
122
|
+
end
|
124
123
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
124
|
+
context "when there is a Procfile in the app's root" do
|
125
|
+
before do
|
126
|
+
File.open("#{path}/Procfile", "w") do |file|
|
127
|
+
file.write("this is a procfile")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "does not ask for a start command" do
|
132
|
+
dont_allow_ask("Startup command")
|
133
|
+
subject
|
134
|
+
end
|
129
135
|
end
|
130
|
-
end
|
131
136
|
|
132
|
-
|
133
|
-
|
134
|
-
|
137
|
+
context "when there is no Procfile in the app's root" do
|
138
|
+
it "asks for a start command" do
|
139
|
+
mock_ask("Custom startup command", :default => "none")
|
140
|
+
subject
|
141
|
+
end
|
142
|
+
end
|
135
143
|
end
|
136
144
|
end
|
137
145
|
|
138
|
-
|
139
|
-
|
140
|
-
mock_ask("Custom startup command", :default => "none")
|
141
|
-
subject
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
+
it "asks for the memory" do
|
147
|
+
given.delete(:memory)
|
146
148
|
|
147
|
-
|
148
|
-
|
149
|
+
memory_choices = %w(64M 128M 256M 512M 1G)
|
150
|
+
create.stub(:memory_choices).and_return(memory_choices)
|
149
151
|
|
150
|
-
|
151
|
-
|
152
|
+
mock_ask("Memory Limit", anything) do |_, options|
|
153
|
+
expect(options[:choices]).to eq memory_choices
|
154
|
+
expect(options[:default]).to eq "256M"
|
155
|
+
"1G"
|
156
|
+
end
|
152
157
|
|
153
|
-
|
154
|
-
|
155
|
-
expect(options[:default]).to eq "256M"
|
156
|
-
"1G"
|
158
|
+
subject
|
159
|
+
end
|
157
160
|
end
|
158
|
-
|
159
|
-
subject
|
160
161
|
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe '#create_app' do
|
165
|
-
before { dont_allow_ask }
|
166
|
-
|
167
|
-
let(:app) { fake(:app, :guid => nil) }
|
168
|
-
let(:space) { fake(:space, :name => "some-space") }
|
169
|
-
|
170
|
-
let(:attributes) do
|
171
|
-
{ :name => "some-app",
|
172
|
-
:total_instances => 2,
|
173
|
-
:memory => 1024,
|
174
|
-
:buildpack => "git://example.com"
|
175
|
-
}
|
176
|
-
end
|
177
162
|
|
178
|
-
|
179
|
-
|
180
|
-
stub(client).current_space { space }
|
181
|
-
end
|
163
|
+
describe "#create_app" do
|
164
|
+
before { dont_allow_ask }
|
182
165
|
|
183
|
-
|
166
|
+
let(:app) { double(:app, :name => "some-app").as_null_object }
|
167
|
+
let(:space) { double(:space, :name => "some-space") }
|
184
168
|
|
185
|
-
|
186
|
-
|
169
|
+
let(:attributes) do
|
170
|
+
{:name => "some-app",
|
171
|
+
:total_instances => 2,
|
172
|
+
:memory => 1024,
|
173
|
+
:buildpack => "git://example.com"
|
174
|
+
}
|
175
|
+
end
|
187
176
|
|
188
|
-
|
177
|
+
before do
|
178
|
+
client.stub(:app).and_return(app)
|
179
|
+
client.stub(:current_space).and_return(space)
|
180
|
+
end
|
189
181
|
|
190
|
-
|
182
|
+
subject { create.create_app(attributes) }
|
191
183
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
end
|
184
|
+
context "when the user does not have permission to create apps" do
|
185
|
+
it "fails with a friendly message" do
|
186
|
+
app.stub(:create!).and_raise(CFoundry::NotAuthorized, "foo")
|
196
187
|
|
197
|
-
|
198
|
-
|
199
|
-
|
188
|
+
expect { subject }.to raise_error(
|
189
|
+
CF::UserError,
|
190
|
+
"You need the Project Developer role in some-space to push.")
|
191
|
+
end
|
192
|
+
end
|
200
193
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
194
|
+
context "with an invalid buildpack" do
|
195
|
+
before do
|
196
|
+
app.stub(:create!) do
|
197
|
+
raise CFoundry::MessageParseError.new(
|
198
|
+
"Request invalid due to parse error: Field: buildpack, Error: Value git@github.com:cloudfoundry/heroku-buildpack-ruby.git doesn't match regexp String /GIT_URL_REGEX/",
|
199
|
+
1001)
|
200
|
+
end
|
201
|
+
end
|
206
202
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
1001)
|
203
|
+
it "fails and prints a pretty message" do
|
204
|
+
create.stub(:line).with(anything)
|
205
|
+
expect { subject }.to raise_error(
|
206
|
+
CF::UserError, "Buildpack must be a public git repository URI.")
|
207
|
+
end
|
213
208
|
end
|
214
209
|
end
|
215
210
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
end
|
222
|
-
end
|
211
|
+
describe "#map_url" do
|
212
|
+
let(:app) { double(:app, :space => space).as_null_object }
|
213
|
+
let(:space) { double(:space, :domains => domains) }
|
214
|
+
let(:domains) { [double(:domain, :name => "foo.com")] }
|
215
|
+
let(:hosts) { [app.name] }
|
223
216
|
|
224
|
-
|
225
|
-
let(:app) { fake(:app, :space => space) }
|
226
|
-
let(:space) { fake(:space, :domains => domains) }
|
227
|
-
let(:domains) { [fake(:domain, :name => "foo.com")] }
|
228
|
-
let(:hosts) { [app.name] }
|
217
|
+
subject { create.map_route(app) }
|
229
218
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
hosts.first
|
237
|
-
end
|
219
|
+
it "asks for a subdomain with 'none' as an option" do
|
220
|
+
mock_ask("Subdomain", anything) do |_, options|
|
221
|
+
expect(options[:choices]).to eq(hosts + %w(none))
|
222
|
+
expect(options[:default]).to eq hosts.first
|
223
|
+
hosts.first
|
224
|
+
end
|
238
225
|
|
239
|
-
|
226
|
+
stub_ask("Domain", anything) { domains.first }
|
240
227
|
|
241
|
-
|
228
|
+
create.stub(:invoke)
|
242
229
|
|
243
|
-
|
244
|
-
|
230
|
+
subject
|
231
|
+
end
|
245
232
|
|
246
|
-
|
247
|
-
|
233
|
+
it "asks for a domain with 'none' as an option" do
|
234
|
+
stub_ask("Subdomain", anything) { hosts.first }
|
248
235
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
236
|
+
mock_ask("Domain", anything) do |_, options|
|
237
|
+
expect(options[:choices]).to eq(domains + %w(none))
|
238
|
+
expect(options[:default]).to eq domains.first
|
239
|
+
domains.first
|
240
|
+
end
|
254
241
|
|
255
|
-
|
242
|
+
create.stub(:invoke)
|
256
243
|
|
257
|
-
|
258
|
-
|
244
|
+
subject
|
245
|
+
end
|
259
246
|
|
260
|
-
|
261
|
-
|
262
|
-
|
247
|
+
it "maps the host and domain after both are given" do
|
248
|
+
stub_ask("Subdomain", anything) { hosts.first }
|
249
|
+
stub_ask("Domain", anything) { domains.first }
|
263
250
|
|
264
|
-
|
265
|
-
|
266
|
-
|
251
|
+
create.should_receive(:invoke).with(:map,
|
252
|
+
:app => app, :host => hosts.first,
|
253
|
+
:domain => domains.first)
|
267
254
|
|
268
|
-
|
269
|
-
|
255
|
+
subject
|
256
|
+
end
|
270
257
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
258
|
+
context "when 'none' is given as the host" do
|
259
|
+
context "and a domain is provided afterwards" do
|
260
|
+
it "invokes 'map' with an empty host" do
|
261
|
+
mock_ask("Subdomain", anything) { "none" }
|
262
|
+
stub_ask("Domain", anything) { domains.first }
|
276
263
|
|
277
|
-
|
278
|
-
|
264
|
+
create.should_receive(:invoke).with(:map,
|
265
|
+
:host => "", :domain => domains.first, :app => app)
|
279
266
|
|
280
|
-
|
267
|
+
subject
|
268
|
+
end
|
269
|
+
end
|
281
270
|
end
|
282
|
-
end
|
283
|
-
end
|
284
271
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
272
|
+
context "when 'none' is given as the domain" do
|
273
|
+
it "does not perform any mapping" do
|
274
|
+
stub_ask("Subdomain", anything) { "foo" }
|
275
|
+
mock_ask("Domain", anything) { "none" }
|
289
276
|
|
290
|
-
|
277
|
+
create.should_not_receive(:invoke).with(:map, anything)
|
291
278
|
|
292
|
-
|
293
|
-
|
294
|
-
|
279
|
+
subject
|
280
|
+
end
|
281
|
+
end
|
295
282
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
283
|
+
context "when mapping fails" do
|
284
|
+
before do
|
285
|
+
mock_ask("Subdomain", anything) { "foo" }
|
286
|
+
mock_ask("Domain", anything) { domains.first }
|
300
287
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
288
|
+
create.should_receive(:invoke).with(:map,
|
289
|
+
:host => "foo", :domain => domains.first, :app => app) do
|
290
|
+
raise CFoundry::RouteHostTaken.new("foo", 1234)
|
291
|
+
end
|
292
|
+
end
|
306
293
|
|
307
|
-
|
308
|
-
|
294
|
+
it "asks again" do
|
295
|
+
create.stub(:line)
|
309
296
|
|
310
|
-
|
311
|
-
|
297
|
+
mock_ask("Subdomain", anything) { hosts.first }
|
298
|
+
mock_ask("Domain", anything) { domains.first }
|
312
299
|
|
313
|
-
|
300
|
+
create.stub(:invoke)
|
314
301
|
|
315
|
-
|
316
|
-
|
302
|
+
subject
|
303
|
+
end
|
317
304
|
|
318
|
-
|
319
|
-
|
320
|
-
|
305
|
+
it "reports the failure message" do
|
306
|
+
create.should_receive(:line).with("foo")
|
307
|
+
create.should_receive(:line)
|
321
308
|
|
322
|
-
|
323
|
-
|
309
|
+
stub_ask("Subdomain", anything) { hosts.first }
|
310
|
+
stub_ask("Domain", anything) { domains.first }
|
324
311
|
|
325
|
-
|
312
|
+
create.stub(:invoke)
|
326
313
|
|
327
|
-
|
314
|
+
subject
|
315
|
+
end
|
316
|
+
end
|
328
317
|
end
|
329
|
-
end
|
330
|
-
end
|
331
318
|
|
332
|
-
|
333
|
-
|
334
|
-
|
319
|
+
describe "#create_services" do
|
320
|
+
let(:app) { fake(:app) }
|
321
|
+
subject { create.create_services(app) }
|
335
322
|
|
336
|
-
|
337
|
-
|
323
|
+
context "when forcing" do
|
324
|
+
let(:inputs) { {:force => true} }
|
338
325
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
326
|
+
it "does not ask to create any services" do
|
327
|
+
dont_allow_ask("Create services for application?", anything)
|
328
|
+
subject
|
329
|
+
end
|
343
330
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
331
|
+
it "does not create any services" do
|
332
|
+
create.should_not_receive(:invoke).with(:create_service, anything)
|
333
|
+
subject
|
334
|
+
end
|
335
|
+
end
|
349
336
|
|
350
|
-
|
351
|
-
|
337
|
+
context "when not forcing" do
|
338
|
+
let(:inputs) { {:force => false} }
|
352
339
|
|
353
|
-
|
354
|
-
|
355
|
-
|
340
|
+
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)
|
356
343
|
|
357
|
-
|
358
|
-
|
344
|
+
subject
|
345
|
+
end
|
359
346
|
|
360
|
-
|
361
|
-
|
362
|
-
|
347
|
+
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
|
363
350
|
|
364
|
-
|
365
|
-
|
351
|
+
mock_ask("Create another service?", :default => false) { true }
|
352
|
+
create.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
|
366
353
|
|
367
|
-
|
368
|
-
|
354
|
+
mock_ask("Create another service?", :default => false) { true }
|
355
|
+
create.should_receive(:invoke).with(:create_service, {:app => app}, :plan => :interact).ordered
|
369
356
|
|
370
|
-
|
371
|
-
|
357
|
+
mock_ask("Create another service?", :default => false) { false }
|
358
|
+
create.should_not_receive(:invoke).with(:create_service, anything).ordered
|
372
359
|
|
373
|
-
|
360
|
+
subject
|
361
|
+
end
|
362
|
+
end
|
374
363
|
end
|
375
|
-
end
|
376
|
-
end
|
377
364
|
|
378
|
-
|
379
|
-
|
365
|
+
describe "#bind_services" do
|
366
|
+
let(:app) { double(:app).as_null_object }
|
380
367
|
|
381
|
-
|
368
|
+
subject { create.bind_services(app) }
|
382
369
|
|
383
|
-
|
384
|
-
|
370
|
+
context "when forcing" do
|
371
|
+
let(:global) { {:force => true, :color => false, :quiet => true} }
|
385
372
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
373
|
+
it "does not ask to bind any services" do
|
374
|
+
dont_allow_ask("Bind other services to application?", anything)
|
375
|
+
subject
|
376
|
+
end
|
390
377
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
378
|
+
it "does not bind any services" do
|
379
|
+
create.should_not_receive(:invoke).with(:bind_service, anything)
|
380
|
+
subject
|
381
|
+
end
|
382
|
+
end
|
396
383
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
384
|
+
context "when not forcing" do
|
385
|
+
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)
|
401
388
|
|
402
|
-
|
403
|
-
|
389
|
+
subject
|
390
|
+
end
|
404
391
|
|
405
|
-
|
406
|
-
|
407
|
-
|
392
|
+
it "asks again to bind a service" do
|
393
|
+
bind_times = 3
|
394
|
+
call_count = 0
|
408
395
|
|
409
|
-
|
396
|
+
mock_ask("Bind other services to application?", anything) { true }
|
410
397
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
398
|
+
create.should_receive(:invoke).with(:bind_service, :app => app).exactly(bind_times).times do
|
399
|
+
call_count += 1
|
400
|
+
app.stub(:services).and_return(service_instances.first(call_count))
|
401
|
+
end
|
415
402
|
|
416
|
-
|
417
|
-
|
418
|
-
|
403
|
+
mock_ask("Bind another service?", anything).exactly(bind_times).times do
|
404
|
+
call_count < bind_times
|
405
|
+
end
|
419
406
|
|
420
|
-
|
421
|
-
|
407
|
+
subject
|
408
|
+
end
|
422
409
|
|
423
|
-
|
424
|
-
|
425
|
-
|
410
|
+
it "stops asking if there are no more services to bind" do
|
411
|
+
bind_times = service_instances.size
|
412
|
+
call_count = 0
|
426
413
|
|
427
|
-
|
414
|
+
mock_ask("Bind other services to application?", anything) { true }
|
428
415
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
416
|
+
create.should_receive(:invoke).with(:bind_service, :app => app).exactly(bind_times).times do
|
417
|
+
call_count += 1
|
418
|
+
app.stub(:services).and_return(service_instances.first(call_count))
|
419
|
+
end
|
433
420
|
|
434
|
-
|
421
|
+
mock_ask("Bind another service?", anything).exactly(bind_times-1).times { true }
|
435
422
|
|
436
|
-
|
437
|
-
|
423
|
+
subject
|
424
|
+
end
|
438
425
|
|
439
|
-
|
440
|
-
|
426
|
+
context "when there are no services" do
|
427
|
+
let(:service_instances) { [] }
|
441
428
|
|
442
|
-
|
443
|
-
|
444
|
-
|
429
|
+
it "does not ask to bind anything" do
|
430
|
+
dont_allow_ask
|
431
|
+
subject
|
432
|
+
end
|
433
|
+
end
|
445
434
|
end
|
446
435
|
end
|
447
|
-
end
|
448
|
-
end
|
449
436
|
|
450
|
-
|
451
|
-
|
452
|
-
|
437
|
+
describe "#start_app" do
|
438
|
+
let(:app) { fake(:app) }
|
439
|
+
subject { create.start_app(app) }
|
453
440
|
|
454
|
-
|
455
|
-
|
441
|
+
context "when the start flag is provided" do
|
442
|
+
let(:inputs) { {:start => true} }
|
456
443
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
444
|
+
it "invokes the start command" do
|
445
|
+
create.should_receive(:invoke).with(:start, :app => app)
|
446
|
+
subject
|
447
|
+
end
|
448
|
+
end
|
462
449
|
|
463
|
-
|
464
|
-
|
450
|
+
context "when the start flag is not provided" do
|
451
|
+
let(:inputs) { {:start => false} }
|
465
452
|
|
466
|
-
|
467
|
-
|
468
|
-
|
453
|
+
it "invokes the start command" do
|
454
|
+
create.should_not_receive(:invoke).with(:start, anything)
|
455
|
+
subject
|
456
|
+
end
|
457
|
+
end
|
469
458
|
end
|
470
|
-
end
|
471
|
-
end
|
472
459
|
|
473
|
-
|
474
|
-
|
460
|
+
describe "#memory_choices" do
|
461
|
+
let(:info) { {} }
|
475
462
|
|
476
|
-
|
477
|
-
|
478
|
-
|
463
|
+
before do
|
464
|
+
client.stub(:info).and_return(info)
|
465
|
+
end
|
479
466
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
467
|
+
context "when the user has usage information" do
|
468
|
+
let(:info) do
|
469
|
+
{:usage => {:memory => 512},
|
470
|
+
:limits => {:memory => 2048}
|
471
|
+
}
|
472
|
+
end
|
486
473
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
474
|
+
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])
|
476
|
+
end
|
477
|
+
end
|
491
478
|
|
492
|
-
|
493
|
-
|
479
|
+
context "when the user does not have usage information" do
|
480
|
+
let(:info) { {:limits => {:memory => 2048}} }
|
494
481
|
|
495
|
-
|
496
|
-
|
482
|
+
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])
|
484
|
+
end
|
485
|
+
end
|
497
486
|
end
|
498
487
|
end
|
499
488
|
end
|