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.
Files changed (59) hide show
  1. data/lib/cf/cli.rb +2 -7
  2. data/lib/cf/cli/organization/delete.rb +4 -6
  3. data/lib/cf/cli/service/create.rb +23 -17
  4. data/lib/cf/cli/space/create.rb +43 -41
  5. data/lib/cf/cli/space/space.rb +49 -46
  6. data/lib/cf/version.rb +1 -1
  7. data/lib/console/console.rb +1 -1
  8. data/spec/cf/cli/app/delete_spec.rb +16 -28
  9. data/spec/cf/cli/app/instances_spec.rb +4 -5
  10. data/spec/cf/cli/app/push/create_spec.rb +362 -373
  11. data/spec/cf/cli/app/push_spec.rb +216 -215
  12. data/spec/cf/cli/app/rename_spec.rb +28 -31
  13. data/spec/cf/cli/app/scale_spec.rb +44 -41
  14. data/spec/cf/cli/app/start_spec.rb +194 -193
  15. data/spec/cf/cli/app/stats_spec.rb +55 -56
  16. data/spec/cf/cli/domain/map_spec.rb +105 -102
  17. data/spec/cf/cli/domain/unmap_spec.rb +60 -56
  18. data/spec/cf/cli/organization/delete_spec.rb +85 -84
  19. data/spec/cf/cli/organization/orgs_spec.rb +80 -83
  20. data/spec/cf/cli/organization/rename_spec.rb +90 -89
  21. data/spec/cf/cli/populators/organization_spec.rb +117 -119
  22. data/spec/cf/cli/populators/space_spec.rb +107 -108
  23. data/spec/cf/cli/populators/target_spec.rb +17 -12
  24. data/spec/cf/cli/route/delete_spec.rb +4 -4
  25. data/spec/cf/cli/route/map_spec.rb +106 -102
  26. data/spec/cf/cli/route/unmap_spec.rb +5 -5
  27. data/spec/cf/cli/service/create_spec.rb +74 -46
  28. data/spec/cf/cli/service/rename_spec.rb +29 -33
  29. data/spec/cf/cli/service/services_spec.rb +48 -48
  30. data/spec/cf/cli/space/base_spec.rb +39 -32
  31. data/spec/cf/cli/space/create_spec.rb +52 -53
  32. data/spec/cf/cli/space/delete_spec.rb +84 -85
  33. data/spec/cf/cli/space/rename_spec.rb +93 -94
  34. data/spec/cf/cli/space/space_spec.rb +60 -60
  35. data/spec/cf/cli/space/spaces_spec.rb +75 -80
  36. data/spec/cf/cli/space/switch_space_spec.rb +45 -48
  37. data/spec/cf/cli/start/info_spec.rb +4 -6
  38. data/spec/cf/cli/start/login_spec.rb +18 -20
  39. data/spec/cf/cli/start/logout_spec.rb +36 -37
  40. data/spec/cf/cli/start/target_spec.rb +86 -89
  41. data/spec/cf/cli/user/create_spec.rb +83 -84
  42. data/spec/cf/cli/user/passwd_spec.rb +87 -86
  43. data/spec/cf/cli/user/register_spec.rb +109 -108
  44. data/spec/cf/cli_spec.rb +305 -310
  45. data/spec/console/console_spec.rb +58 -58
  46. data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
  47. data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
  48. data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
  49. data/spec/features/org_spec.rb +11 -11
  50. data/spec/manifests/manifests_spec.rb +21 -21
  51. data/spec/manifests/plugin_spec.rb +34 -34
  52. data/spec/spec_helper.rb +1 -2
  53. data/spec/support/cli_helper.rb +5 -14
  54. data/spec/support/factory_girl.rb +6 -0
  55. data/spec/support/interact_helper.rb +5 -15
  56. data/spec/support/shared_examples/errors.rb +1 -1
  57. data/spec/tunnel/plugin_spec.rb +2 -2
  58. data/spec/tunnel/tunnel_spec.rb +5 -5
  59. metadata +36 -28
@@ -1,271 +1,272 @@
1
- require 'spec_helper'
2
- require "cf/cli/app/push"
3
-
4
- describe CF::App::Push do
5
- let(:global) { { :color => false, :quiet => true } }
6
- let(:inputs) { {} }
7
- let(:given) { {} }
8
- let(:path) { "somepath" }
9
- let(:client) { fake_client }
10
- let(:push) { CF::App::Push.new(Mothership.commands[:push]) }
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
1
+ require "spec_helper"
18
2
 
19
- describe 'metadata' do
20
- let(:command) { Mothership.commands[:push] }
3
+ module CF
4
+ module App
5
+ describe Push do
6
+ let(:global) { {:color => false, :quiet => true} }
7
+ let(:inputs) { {} }
8
+ let(:given) { {} }
9
+ let(:path) { "somepath" }
10
+ let(:client) { fake_client }
11
+ let(:push) { CF::App::Push.new(Mothership.commands[:push]) }
12
+
13
+ before do
14
+ CF::CLI.any_instance.stub(:client) { client }
15
+ CF::CLI.any_instance.stub(:precondition) { nil }
16
+ end
21
17
 
22
- describe 'command' do
23
- subject { command }
24
- its(:description) { should eq "Push an application, syncing changes if it exists" }
25
- it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
26
- end
18
+ describe 'metadata' do
19
+ let(:command) { Mothership.commands[:push] }
27
20
 
28
- include_examples 'inputs must have descriptions'
21
+ describe 'command' do
22
+ subject { command }
23
+ its(:description) { should eq "Push an application, syncing changes if it exists" }
24
+ it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
25
+ end
29
26
 
30
- describe 'arguments' do
31
- subject { command.arguments }
32
- it 'has the correct argument order' do
33
- should eq([{ :type => :optional, :value => nil, :name => :name }])
27
+ include_examples 'inputs must have descriptions'
28
+
29
+ describe 'arguments' do
30
+ subject { command.arguments }
31
+ it 'has the correct argument order' do
32
+ should eq([{:type => :optional, :value => nil, :name => :name}])
33
+ end
34
+ end
34
35
  end
35
- end
36
- end
37
36
 
38
- describe '#sync_app' do
39
- let(:app) { fake(:app) }
37
+ describe '#sync_app' do
38
+ let(:app) { fake(:app) }
40
39
 
41
- before do
42
- stub(app).upload
43
- app.changes = {}
44
- end
40
+ before do
41
+ app.stub(:upload)
42
+ app.changes = {}
43
+ end
45
44
 
46
- subject do
47
- push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
48
- push.sync_app(app, path)
49
- end
45
+ subject do
46
+ push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
47
+ push.sync_app(app, path)
48
+ end
50
49
 
51
- shared_examples 'common tests for inputs' do |*args|
52
- context 'when the new input is the same as the old' do
53
- type, input = args
54
- input ||= type
50
+ shared_examples 'common tests for inputs' do |*args|
51
+ context 'when the new input is the same as the old' do
52
+ type, input = args
53
+ input ||= type
55
54
 
56
- let(:inputs) { {input => old} }
55
+ let(:inputs) { {input => old} }
57
56
 
58
- it "does not update the app's #{type}" do
59
- dont_allow(push).line
60
- dont_allow(app).update!
61
- expect { subject }.not_to change { app.send(type) }
57
+ it "does not update the app's #{type}" do
58
+ push.should_not_receive(:line)
59
+ app.should_not_receive(:update!)
60
+ expect { subject }.not_to change { app.send(type) }
61
+ end
62
+ end
62
63
  end
63
- end
64
- end
65
64
 
66
- it 'triggers the :push_app filter' do
67
- mock(push).filter(:push_app, app) { app }
68
- subject
69
- end
65
+ it "triggers the :push_app filter" do
66
+ push.should_receive(:filter).with(:push_app, app) { app }
67
+ subject
68
+ end
70
69
 
71
- it 'uploads the app' do
72
- mock(app).upload(path)
73
- subject
74
- end
70
+ it 'uploads the app' do
71
+ app.should_receive(:upload).with(path)
72
+ subject
73
+ end
75
74
 
76
- context 'when no inputs are given' do
77
- let(:inputs) { {} }
75
+ context 'when no inputs are given' do
76
+ let(:inputs) { {} }
78
77
 
79
- it 'should not update the app' do
80
- dont_allow(app).update!
81
- subject
82
- end
78
+ it 'should not update the app' do
79
+ app.should_not_receive(:update!)
80
+ subject
81
+ end
83
82
 
84
- it "should not set memory on the app" do
85
- dont_allow(app).__send__(:memory=)
86
- subject
87
- end
88
- end
83
+ it "should not set memory on the app" do
84
+ app.should_not_receive(:memory=)
85
+ subject
86
+ end
87
+ end
89
88
 
90
- context 'when memory is given' do
91
- let(:old) { 1024 }
92
- let(:new) { "2G" }
93
- let(:app) { fake(:app, :memory => old) }
94
- let(:inputs) { { :memory => new } }
89
+ context 'when memory is given' do
90
+ let(:old) { 1024 }
91
+ let(:new) { "2G" }
92
+ let(:app) { fake(:app, :memory => old) }
93
+ let(:inputs) { {:memory => new} }
95
94
 
96
- it 'updates the app memory, converting to megabytes' do
97
- stub(push).line(anything)
98
- mock(app).update!
99
- expect { subject }.to change { app.memory }.from(old).to(2048)
100
- end
95
+ it 'updates the app memory, converting to megabytes' do
96
+ push.stub(:line)
97
+ app.should_receive(:update!)
98
+ expect { subject }.to change { app.memory }.from(old).to(2048)
99
+ end
101
100
 
102
- it 'outputs the changed memory in human readable sizes' do
103
- mock(push).line("Changes:")
104
- mock(push).line("memory: 1G -> 2G")
105
- stub(app).update!
106
- subject
107
- end
101
+ it 'outputs the changed memory in human readable sizes' do
102
+ push.should_receive(:line).with("Changes:")
103
+ push.should_receive(:line).with("memory: 1G -> 2G")
104
+ app.stub(:update!)
105
+ subject
106
+ end
108
107
 
109
- include_examples 'common tests for inputs', :memory
110
- end
108
+ include_examples 'common tests for inputs', :memory
109
+ end
111
110
 
112
- context 'when instances is given' do
113
- let(:old) { 1 }
114
- let(:new) { 2 }
115
- let(:app) { fake(:app, :total_instances => old) }
116
- let(:inputs) { { :instances => new } }
111
+ context 'when instances is given' do
112
+ let(:old) { 1 }
113
+ let(:new) { 2 }
114
+ let(:app) { fake(:app, :total_instances => old) }
115
+ let(:inputs) { {:instances => new} }
117
116
 
118
- it 'updates the app instances' do
119
- stub(push).line(anything)
120
- mock(app).update!
121
- expect { subject }.to change { app.total_instances }.from(old).to(new)
122
- end
117
+ it 'updates the app instances' do
118
+ push.stub(:line)
119
+ app.stub(:update!)
120
+ expect { subject }.to change { app.total_instances }.from(old).to(new)
121
+ end
123
122
 
124
- it 'outputs the changed instances' do
125
- mock(push).line("Changes:")
126
- mock(push).line("total_instances: 1 -> 2")
127
- stub(app).update!
128
- subject
129
- end
123
+ it 'outputs the changed instances' do
124
+ push.should_receive(:line).with("Changes:")
125
+ push.should_receive(:line).with("total_instances: 1 -> 2")
126
+ app.stub(:update!)
127
+ subject
128
+ end
130
129
 
131
- include_examples 'common tests for inputs', :total_instances, :instances
132
- end
130
+ include_examples 'common tests for inputs', :total_instances, :instances
131
+ end
133
132
 
134
- context 'when command is given' do
135
- let(:old) { "./start" }
136
- let(:new) { "./start foo " }
137
- let(:app) { fake(:app, :command => old) }
138
- let(:inputs) { { :command => new } }
133
+ context 'when command is given' do
134
+ let(:old) { "./start" }
135
+ let(:new) { "./start foo " }
136
+ let(:app) { fake(:app, :command => old) }
137
+ let(:inputs) { {:command => new} }
139
138
 
140
- it 'updates the app command' do
141
- stub(push).line(anything)
142
- mock(app).update!
143
- expect { subject }.to change { app.command }.from("./start").to("./start foo ")
144
- end
139
+ it 'updates the app command' do
140
+ push.stub(:line)
141
+ app.should_receive(:update!)
142
+ expect { subject }.to change { app.command }.from("./start").to("./start foo ")
143
+ end
145
144
 
146
- it 'outputs the changed command in single quotes' do
147
- mock(push).line("Changes:")
148
- mock(push).line("command: './start' -> './start foo '")
149
- stub(app).update!
150
- subject
151
- end
145
+ it 'outputs the changed command in single quotes' do
146
+ push.should_receive(:line).with("Changes:")
147
+ push.should_receive(:line).with("command: './start' -> './start foo '")
148
+ app.stub(:update!)
149
+ subject
150
+ end
152
151
 
153
- include_examples 'common tests for inputs', :command
154
- end
152
+ include_examples 'common tests for inputs', :command
153
+ end
155
154
 
156
- context 'when restart is given' do
157
- let(:inputs) { { :restart => true, :memory => 4096 } }
155
+ context 'when restart is given' do
156
+ let(:inputs) { {:restart => true, :memory => 4096} }
158
157
 
159
158
 
160
- context 'when the app is already started' do
161
- let(:app) { fake(:app, :state => "STARTED") }
159
+ context 'when the app is already started' do
160
+ let(:app) { fake(:app, :state => "STARTED") }
162
161
 
163
- it 'invokes the restart command' do
164
- stub(push).line
165
- mock(app).update!
166
- mock(push).invoke(:restart, :app => app)
167
- subject
168
- end
162
+ it 'invokes the restart command' do
163
+ push.stub(:line)
164
+ app.should_receive(:update!)
165
+ push.should_receive(:invoke).with(:restart, :app => app)
166
+ subject
167
+ end
169
168
 
170
- context 'but there are no changes' do
171
- let(:inputs) { { :restart => true } }
169
+ context 'but there are no changes' do
170
+ let(:inputs) { {:restart => true} }
172
171
 
173
- it 'invokes the restart command' do
174
- stub(push).line
175
- dont_allow(app).update!
176
- mock(push).invoke(:restart, :app => app)
177
- subject
172
+ it 'invokes the restart command' do
173
+ push.stub(:line)
174
+ app.should_not_receive(:update!)
175
+ push.should_receive(:invoke).with(:restart, :app => app)
176
+ subject
177
+ end
178
+ end
178
179
  end
179
- end
180
- end
181
180
 
182
- context 'when the app is not already started' do
183
- let(:app) { fake(:app, :state => "STOPPED") }
181
+ context 'when the app is not already started' do
182
+ let(:app) { fake(:app, :state => "STOPPED") }
184
183
 
185
- it 'does not invoke the restart command' do
186
- stub(push).line
187
- mock(app).update!
188
- dont_allow(push).invoke(:restart, :app => app)
189
- subject
184
+ it 'does not invoke the restart command' do
185
+ push.stub(:line)
186
+ app.should_receive(:update!)
187
+ push.should_not_receive(:invoke).with(:restart, :app => app)
188
+ subject
189
+ end
190
+ end
190
191
  end
191
- end
192
- end
193
192
 
194
- context "when buildpack is given" do
195
- let(:old) { nil }
196
- let(:app) { fake(:app, :buildpack => old) }
197
- let(:inputs) { { :buildpack => new } }
193
+ context "when buildpack is given" do
194
+ let(:old) { nil }
195
+ let(:app) { fake(:app, :buildpack => old) }
196
+ let(:inputs) { {:buildpack => new} }
197
+
198
+ context "and it's an invalid URL" do
199
+ let(:new) { "git@github.com:foo/bar.git" }
200
+
201
+ before do
202
+ app.stub(:update!) do
203
+ raise CFoundry::MessageParseError.new(
204
+ "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/",
205
+ 1001)
206
+ end
207
+ end
208
+
209
+ it "fails and prints a pretty message" do
210
+ push.stub(:line)
211
+ expect { subject }.to raise_error(
212
+ CF::UserError, "Buildpack must be a public git repository URI.")
213
+ end
214
+ end
198
215
 
199
- context "and it's an invalid URL" do
200
- let(:new) { "git@github.com:foo/bar.git" }
216
+ context "and it's a valid URL" do
217
+ let(:new) { "git://github.com/foo/bar.git" }
201
218
 
202
- before do
203
- stub(app).update! do
204
- raise CFoundry::MessageParseError.new(
205
- "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/",
206
- 1001)
219
+ it "updates the app's buildpack" do
220
+ push.stub(:line)
221
+ app.should_receive(:update!)
222
+ expect { subject }.to change { app.buildpack }.from(old).to(new)
223
+ end
224
+
225
+ it "outputs the changed buildpack with single quotes" do
226
+ push.should_receive(:line).with("Changes:")
227
+ push.should_receive(:line).with("buildpack: '' -> '#{new}'")
228
+ app.stub(:update!)
229
+ subject
230
+ end
231
+
232
+ include_examples 'common tests for inputs', :buildpack
207
233
  end
208
234
  end
235
+ end
209
236
 
210
- it "fails and prints a pretty message" do
211
- stub(push).line(anything)
212
- expect { subject }.to raise_error(
213
- CF::UserError, "Buildpack must be a public git repository URI.")
237
+ describe '#setup_new_app (integration spec!!)' do
238
+ let(:app) { fake(:app, :guid => nil) }
239
+ let(:host) { "" }
240
+ let(:domain) { fake(:domain, :name => "example.com") }
241
+ let(:inputs) do
242
+ {:name => "some-app",
243
+ :instances => 2,
244
+ :memory => 1024,
245
+ :host => host,
246
+ :domain => domain
247
+ }
214
248
  end
215
- end
249
+ let(:global) { {:quiet => true, :color => false, :force => true} }
216
250
 
217
- context "and it's a valid URL" do
218
- let(:new) { "git://github.com/foo/bar.git" }
251
+ before do
252
+ client.stub(:app) { app }
253
+ end
219
254
 
220
- it "updates the app's buildpack" do
221
- stub(push).line(anything)
222
- mock(app).update!
223
- expect { subject }.to change { app.buildpack }.from(old).to(new)
255
+ subject do
256
+ push.input = Mothership::Inputs.new(Mothership.commands[:push], push, inputs, global, global)
257
+ push.setup_new_app(path)
224
258
  end
225
259
 
226
- it "outputs the changed buildpack with single quotes" do
227
- mock(push).line("Changes:")
228
- mock(push).line("buildpack: '' -> '#{new}'")
229
- stub(app).update!
260
+ it 'creates the app' do
261
+ app.should_receive(:create!)
262
+ app.should_receive(:upload).with(path)
263
+ push.should_receive(:filter).with(:create_app, app) { app }
264
+ push.should_receive(:filter).with(:push_app, app) { app }
265
+ push.should_receive(:invoke).with(:map, :app => app, :host => host, :domain => domain)
266
+ push.should_receive(:invoke).with(:start, :app => app)
230
267
  subject
231
268
  end
232
-
233
- include_examples 'common tests for inputs', :buildpack
234
269
  end
235
270
  end
236
271
  end
237
-
238
- describe '#setup_new_app (integration spec!!)' do
239
- let(:app) { fake(:app, :guid => nil) }
240
- let(:host) { "" }
241
- let(:domain) { fake(:domain, :name => "example.com") }
242
- let(:inputs) do
243
- { :name => "some-app",
244
- :instances => 2,
245
- :memory => 1024,
246
- :host => host,
247
- :domain => domain
248
- }
249
- end
250
- let(:global) { {:quiet => true, :color => false, :force => true} }
251
-
252
- before do
253
- stub(client).app { app }
254
- end
255
-
256
- subject do
257
- push.input = Mothership::Inputs.new(Mothership.commands[:push], push, inputs, global, global)
258
- push.setup_new_app(path)
259
- end
260
-
261
- it 'creates the app' do
262
- mock(app).create!
263
- mock(app).upload(path)
264
- mock(push).filter(:create_app, app) { app }
265
- mock(push).filter(:push_app, app) { app }
266
- mock(push).invoke :map, :app => app, :host => host, :domain => domain
267
- mock(push).invoke :start, :app => app
268
- subject
269
- end
270
- end
271
272
  end