rhc 1.6.8 → 1.7.8
Sign up to get free protection for your applications and to get access to all the features.
- data/autocomplete/rhc_bash +1167 -0
- data/features/README.md +1 -1
- data/features/domain.feature +1 -1
- data/features/lib/rhc_helper/persistable.rb +4 -1
- data/features/multiple_cartridge.feature +4 -3
- data/features/sshkey.feature +3 -3
- data/features/support/assumptions.rb +3 -3
- data/features/support/env.rb +10 -0
- data/features/support/platform_support.rb +2 -2
- data/lib/rhc.rb +6 -0
- data/lib/rhc/auth/token.rb +4 -0
- data/lib/rhc/autocomplete.rb +50 -52
- data/lib/rhc/autocomplete_templates/{rhc.erb → bash.erb} +8 -2
- data/lib/rhc/cartridge_helpers.rb +1 -1
- data/lib/rhc/cli.rb +1 -7
- data/lib/rhc/command_runner.rb +45 -16
- data/lib/rhc/commands.rb +75 -55
- data/lib/rhc/commands/account.rb +7 -51
- data/lib/rhc/commands/alias.rb +26 -17
- data/lib/rhc/commands/app.rb +75 -39
- data/lib/rhc/commands/authorization.rb +4 -2
- data/lib/rhc/commands/base.rb +31 -29
- data/lib/rhc/commands/cartridge.rb +66 -44
- data/lib/rhc/commands/domain.rb +20 -8
- data/lib/rhc/commands/git_clone.rb +3 -3
- data/lib/rhc/commands/logout.rb +51 -0
- data/lib/rhc/commands/port_forward.rb +15 -11
- data/lib/rhc/commands/setup.rb +25 -0
- data/lib/rhc/commands/snapshot.rb +20 -10
- data/lib/rhc/commands/sshkey.rb +21 -7
- data/lib/rhc/commands/tail.rb +2 -2
- data/lib/rhc/commands/threaddump.rb +2 -2
- data/lib/rhc/context_helper.rb +0 -4
- data/lib/rhc/core_ext.rb +96 -76
- data/lib/rhc/exceptions.rb +6 -0
- data/lib/rhc/help_formatter.rb +19 -2
- data/lib/rhc/helpers.rb +32 -194
- data/lib/rhc/highline_extensions.rb +412 -0
- data/lib/rhc/output_helpers.rb +31 -67
- data/lib/rhc/rest.rb +4 -2
- data/lib/rhc/rest/alias.rb +0 -2
- data/lib/rhc/rest/application.rb +9 -4
- data/lib/rhc/rest/authorization.rb +0 -2
- data/lib/rhc/rest/base.rb +1 -1
- data/lib/rhc/rest/client.rb +11 -9
- data/lib/rhc/rest/domain.rb +5 -1
- data/lib/rhc/rest/gear_group.rb +0 -2
- data/lib/rhc/rest/key.rb +0 -2
- data/lib/rhc/rest/mock.rb +32 -10
- data/lib/rhc/ssh_helpers.rb +2 -2
- data/lib/rhc/usage_templates/command_help.erb +20 -13
- data/lib/rhc/usage_templates/command_syntax_help.erb +1 -3
- data/lib/rhc/usage_templates/help.erb +15 -16
- data/lib/rhc/usage_templates/options_help.erb +7 -9
- data/lib/rhc/wizard.rb +193 -159
- data/spec/rest_spec_helper.rb +2 -2
- data/spec/rhc/cli_spec.rb +36 -5
- data/spec/rhc/command_spec.rb +94 -42
- data/spec/rhc/commands/account_spec.rb +1 -75
- data/spec/rhc/commands/alias_spec.rb +28 -28
- data/spec/rhc/commands/app_spec.rb +141 -33
- data/spec/rhc/commands/apps_spec.rb +4 -4
- data/spec/rhc/commands/authorization_spec.rb +8 -8
- data/spec/rhc/commands/cartridge_spec.rb +18 -9
- data/spec/rhc/commands/domain_spec.rb +16 -16
- data/spec/rhc/commands/git_clone_spec.rb +3 -3
- data/spec/rhc/commands/logout_spec.rb +86 -0
- data/spec/rhc/commands/port_forward_spec.rb +9 -9
- data/spec/rhc/commands/server_spec.rb +5 -5
- data/spec/rhc/commands/setup_spec.rb +19 -5
- data/spec/rhc/commands/snapshot_spec.rb +12 -12
- data/spec/rhc/commands/sshkey_spec.rb +11 -11
- data/spec/rhc/commands/tail_spec.rb +5 -5
- data/spec/rhc/commands/threaddump_spec.rb +3 -3
- data/spec/rhc/config_spec.rb +6 -6
- data/spec/rhc/helpers_spec.rb +72 -219
- data/spec/rhc/highline_extensions_spec.rb +269 -0
- data/spec/rhc/rest_application_spec.rb +28 -1
- data/spec/rhc/rest_client_spec.rb +20 -21
- data/spec/rhc/rest_spec.rb +10 -0
- data/spec/rhc/wizard_spec.rb +72 -32
- data/spec/spec_helper.rb +86 -56
- data/spec/wizard_spec_helper.rb +7 -4
- metadata +165 -160
- data/spec/spec.opts +0 -1
@@ -6,12 +6,13 @@ require 'resolv'
|
|
6
6
|
|
7
7
|
describe RHC::Commands::App do
|
8
8
|
let!(:rest_client){ MockRestClient.new }
|
9
|
-
|
9
|
+
let!(:config){ user_config }
|
10
|
+
before{ RHC::Config.stub(:home_dir).and_return('/home/mock_user') }
|
11
|
+
before do
|
10
12
|
FakeFS.activate!
|
11
13
|
FakeFS::FileSystem.clear
|
12
|
-
|
13
|
-
RHC::Helpers
|
14
|
-
RHC::Helpers::const_set(:MAX_RETRIES, 3)
|
14
|
+
RHC::Helpers.send(:remove_const, :MAX_RETRIES) rescue nil
|
15
|
+
RHC::Helpers.const_set(:MAX_RETRIES, 3)
|
15
16
|
@instance = RHC::Commands::App.new
|
16
17
|
RHC::Commands::App.stub(:new) do
|
17
18
|
@instance.stub(:git_config_get) { "" }
|
@@ -38,7 +39,7 @@ describe RHC::Commands::App do
|
|
38
39
|
end
|
39
40
|
|
40
41
|
context 'app' do
|
41
|
-
let(:arguments) { ['app'
|
42
|
+
let(:arguments) { ['app'] }
|
42
43
|
it { run_output.should match('Usage:') }
|
43
44
|
end
|
44
45
|
end
|
@@ -49,9 +50,116 @@ describe RHC::Commands::App do
|
|
49
50
|
it("shows number of started"){ subject.send(:gear_group_state, ['started', 'idle']).should == '1/2 started' }
|
50
51
|
end
|
51
52
|
|
53
|
+
describe '#check_domain!' do
|
54
|
+
let(:rest_client){ stub('RestClient') }
|
55
|
+
let(:domain){ stub('Domain', :id => 'test') }
|
56
|
+
before{ subject.stub(:rest_client).and_return(rest_client) }
|
57
|
+
let(:interactive){ false }
|
58
|
+
before{ subject.stub(:interactive?).and_return(interactive) }
|
59
|
+
|
60
|
+
context "when no options are provided and there is one domain" do
|
61
|
+
before{ rest_client.should_receive(:domains).twice.and_return([domain]) }
|
62
|
+
it("should load the first domain"){ subject.send(:check_domain!).should == domain }
|
63
|
+
after{ subject.send(:options).namespace.should == domain.id }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when no options are provided and there are no domains" do
|
67
|
+
before{ rest_client.should_receive(:domains).and_return([]) }
|
68
|
+
it("should load the first domain"){ expect{ subject.send(:check_domain!) }.to raise_error(RHC::Rest::DomainNotFoundException) }
|
69
|
+
after{ subject.send(:options).namespace.should be_nil }
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when valid namespace is provided" do
|
73
|
+
before{ subject.send(:options)[:namespace] = 'test' }
|
74
|
+
before{ rest_client.should_receive(:find_domain).with('test').and_return(domain) }
|
75
|
+
it("should load the requested domain"){ subject.send(:check_domain!).should == domain }
|
76
|
+
after{ subject.send(:options).namespace.should == 'test' }
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when interactive and no domains" do
|
80
|
+
let(:interactive){ true }
|
81
|
+
before{ rest_client.should_receive(:domains).twice.and_return([]) }
|
82
|
+
before{ RHC::DomainWizard.should_receive(:new).and_return(stub(:run => true)) }
|
83
|
+
it("should raise if the wizard doesn't set the option"){ expect{ subject.send(:check_domain!) }.to raise_error(RHC::Rest::DomainNotFoundException) }
|
84
|
+
after{ subject.send(:options).namespace.should be_nil }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
52
88
|
describe 'app create' do
|
53
|
-
before(
|
54
|
-
|
89
|
+
before{ rest_client.add_domain("mockdomain") }
|
90
|
+
|
91
|
+
context "when we ask for help with the alias" do
|
92
|
+
before{ FakeFS.deactivate! }
|
93
|
+
context do
|
94
|
+
let(:arguments) { ['help', 'create-app'] }
|
95
|
+
it{ run_output.should match "Usage: rhc app-create <name>" }
|
96
|
+
end
|
97
|
+
context do
|
98
|
+
let(:arguments) { ['create-app', '-h'] }
|
99
|
+
it{ run_output.should match "Usage: rhc app-create <name>" }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when run with no arguments" do
|
104
|
+
before{ FakeFS.deactivate! }
|
105
|
+
let(:arguments){ ['create-app'] }
|
106
|
+
it{ run_output.should match "Usage: rhc app-create <name>" }
|
107
|
+
it{ run_output.should match "When creating an application, you must provide a name and a cartridge from the list below:" }
|
108
|
+
it{ run_output.should match "mock_standalone_cart-1" }
|
109
|
+
it{ run_output.should match "Please specify the name of the application" }
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when dealing with config" do
|
113
|
+
subject{ described_class.new(Commander::Command::Options.new(options)) }
|
114
|
+
let(:wizard){ s = stub('Wizard'); RHC::EmbeddedWizard.should_receive(:new).and_return(s); s }
|
115
|
+
let(:options){ nil }
|
116
|
+
let(:interactive){ true }
|
117
|
+
before{ subject.should_receive(:interactive?).at_least(1).times.and_return(interactive) }
|
118
|
+
before{ subject.stub(:check_sshkeys!) }
|
119
|
+
|
120
|
+
it("should run the wizard"){ expect{ subject.create('name', ['mock_standalone_cart-1']) }.to call(:run).on(wizard).and_stop }
|
121
|
+
|
122
|
+
context "when has config" do
|
123
|
+
let(:options){ {:server => 'test', :rhlogin => 'foo'} }
|
124
|
+
before{ subject.send(:config).should_receive(:has_local_config?).and_return(true) }
|
125
|
+
it("should not run the wizard"){ expect{ subject.create('name', ['mock_standalone_cart-1']) }.to not_call(:new).on(RHC::EmbeddedWizard) }
|
126
|
+
end
|
127
|
+
|
128
|
+
context "when has no config" do
|
129
|
+
before{ subject.send(:config).should_receive(:has_local_config?).and_return(false) }
|
130
|
+
it("should run the wizard"){ expect{ subject.create('name', ['mock_standalone_cart-1']) }.to call(:new).on(RHC::EmbeddedWizard).and_stop }
|
131
|
+
end
|
132
|
+
|
133
|
+
context "when not interactive" do
|
134
|
+
let(:interactive){ false }
|
135
|
+
it("should not run the wizard"){ expect{ subject.create('name', ['mock_standalone_cart-1']) }.to not_call(:new).on(RHC::EmbeddedWizard) }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "when dealing with ssh keys" do
|
140
|
+
subject{ described_class.new(options) }
|
141
|
+
let(:wizard){ s = stub('Wizard'); RHC::SSHWizard.should_receive(:new).and_return(s); s }
|
142
|
+
let(:options){ Commander::Command::Options.new(:server => 'foo.com', :rhlogin => 'test') }
|
143
|
+
let(:interactive){ true }
|
144
|
+
before{ subject.should_receive(:interactive?).at_least(1).times.and_return(interactive) }
|
145
|
+
before{ subject.should_receive(:check_config!) }
|
146
|
+
|
147
|
+
it("should run the wizard"){ expect{ subject.create('name', ['mock_standalone_cart-1']) }.to call(:run).on(wizard).and_stop }
|
148
|
+
|
149
|
+
context "when not interactive" do
|
150
|
+
let(:interactive){ false }
|
151
|
+
it("should not run the wizard"){ expect{ subject.create('name', ['mock_standalone_cart-1']) }.to not_call(:new).on(RHC::SSHWizard) }
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context "when in full interactive mode with no keys, domain, or config" do
|
156
|
+
let!(:config){ base_config }
|
157
|
+
before{ RHC::Config.any_instance.stub(:has_local_config?).and_return(false) }
|
158
|
+
before{ described_class.any_instance.stub(:interactive?).and_return(true) }
|
159
|
+
before{ rest_client.domains.clear }
|
160
|
+
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1'] }
|
161
|
+
# skips login stage and insecure check because of mock rest client, doesn't check keys
|
162
|
+
it { run_output(['mydomain', 'y', 'mykey']).should match(/This wizard.*Checking your namespace.*Your domain name 'mydomain' has been successfully created.*Creating application.*Your public SSH key.*Uploading key 'mykey' .*Downloading the application.*Success/m) }
|
55
163
|
end
|
56
164
|
|
57
165
|
context 'when run without a cart' do
|
@@ -62,7 +170,7 @@ describe RHC::Commands::App do
|
|
62
170
|
|
63
171
|
context 'when run with a valid cart' do
|
64
172
|
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
65
|
-
it { expect { run }.
|
173
|
+
it { expect { run }.to exit_with_code(0) }
|
66
174
|
it { run_output.should match("Success") }
|
67
175
|
it { run_output.should match("Cartridges: mock_standalone_cart-1\n") }
|
68
176
|
end
|
@@ -75,13 +183,13 @@ describe RHC::Commands::App do
|
|
75
183
|
resolver.should_receive(:getaddress).with('app1-mockdomain.fake.foo').and_raise(ArgumentError)
|
76
184
|
end
|
77
185
|
|
78
|
-
it { expect { run }.
|
186
|
+
it { expect { run }.to exit_with_code(0) }
|
79
187
|
it { run_output.should match("Success") }
|
80
188
|
end
|
81
189
|
|
82
190
|
context 'when run with multiple carts' do
|
83
191
|
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', 'mock_cart-1', '--noprompt', '-p', 'password'] }
|
84
|
-
it { expect { run }.
|
192
|
+
it { expect { run }.to exit_with_code(0) }
|
85
193
|
it { run_output.should match("Success") }
|
86
194
|
it { run_output.should match("Cartridges: mock_standalone_cart-1, mock_cart-1\n") }
|
87
195
|
after{ rest_client.domains.first.applications.first.cartridges.find{ |c| c.name == 'mock_cart-1' }.should be_true }
|
@@ -89,7 +197,7 @@ describe RHC::Commands::App do
|
|
89
197
|
|
90
198
|
context 'when run with a git url' do
|
91
199
|
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', '--from', 'git://url', '--noprompt', '-p', 'password'] }
|
92
|
-
it { expect { run }.
|
200
|
+
it { expect { run }.to exit_with_code(0) }
|
93
201
|
it { run_output.should match("Success") }
|
94
202
|
it { run_output.should match("Source Code: git://url\n") }
|
95
203
|
it { run_output.should match("Initial Git URL: git://url\n") }
|
@@ -106,7 +214,7 @@ describe RHC::Commands::App do
|
|
106
214
|
end
|
107
215
|
context 'with trace' do
|
108
216
|
let(:arguments) { ['app', 'create', 'app1', 'nomatch_cart', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', '--trace'] }
|
109
|
-
it { expect { run }.
|
217
|
+
it { expect { run }.to raise_error(RHC::CartridgeNotFoundException, "There are no cartridges that match 'nomatch_cart'.") }
|
110
218
|
end
|
111
219
|
end
|
112
220
|
|
@@ -119,7 +227,7 @@ describe RHC::Commands::App do
|
|
119
227
|
|
120
228
|
context 'multiple web matches' do
|
121
229
|
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart', '--trace', '--noprompt'] }
|
122
|
-
it { expect { run }.
|
230
|
+
it { expect { run }.to raise_error(RHC::MultipleCartridgesException) }
|
123
231
|
end
|
124
232
|
context 'when only a single cart can match' do
|
125
233
|
let(:arguments) { ['app', 'create', 'app1', 'unique', '--trace', '--noprompt'] }
|
@@ -135,15 +243,15 @@ describe RHC::Commands::App do
|
|
135
243
|
end
|
136
244
|
context 'when I pick only embedded carts' do
|
137
245
|
let(:arguments) { ['app', 'create', 'app1', 'mock_cart', '--trace', '--noprompt'] }
|
138
|
-
it { expect { run }.
|
246
|
+
it { expect { run }.to raise_error(RHC::CartridgeNotFoundException, /Every application needs a web cartridge/) }
|
139
247
|
end
|
140
248
|
context 'when I pick multiple embedded carts' do
|
141
249
|
let(:arguments) { ['app', 'create', 'app1', 'unique_standalone', 'mock_cart', '--trace', '--noprompt'] }
|
142
|
-
it { expect { run }.
|
250
|
+
it { expect { run }.to raise_error(RHC::MultipleCartridgesException, /There are multiple cartridges matching 'mock_cart'/) }
|
143
251
|
end
|
144
252
|
context 'when I pick multiple standalone carts' do
|
145
253
|
let(:arguments) { ['app', 'create', 'app1', 'unique_standalone', 'mock_standalone_cart', '--trace', '--noprompt'] }
|
146
|
-
it { expect { run }.
|
254
|
+
it { expect { run }.to raise_error(RHC::MultipleCartridgesException, /You must select only a single web cart/) }
|
147
255
|
end
|
148
256
|
end
|
149
257
|
|
@@ -156,7 +264,7 @@ describe RHC::Commands::App do
|
|
156
264
|
end
|
157
265
|
it "should create a jenkins app and a regular app with an embedded jenkins client" do
|
158
266
|
#puts run_output
|
159
|
-
expect { run }.
|
267
|
+
expect { run }.to exit_with_code(0)
|
160
268
|
jenkins_app = rest_client.find_application(@domain.id,"jenkins")
|
161
269
|
jenkins_app.cartridges[0].name.should == "jenkins-1.4"
|
162
270
|
app = rest_client.find_application(@domain.id,"app1")
|
@@ -172,7 +280,7 @@ describe RHC::Commands::App do
|
|
172
280
|
before(:each) do
|
173
281
|
domain = rest_client.add_domain("mockdomain")
|
174
282
|
end
|
175
|
-
it { expect { run }.
|
283
|
+
it { expect { run }.to_not raise_error(ArgumentError, /The --no-dns option can't be used in conjunction with --enable-jenkins/) }
|
176
284
|
end
|
177
285
|
end
|
178
286
|
|
@@ -183,7 +291,7 @@ describe RHC::Commands::App do
|
|
183
291
|
before(:each) do
|
184
292
|
domain = rest_client.add_domain("mockdomain")
|
185
293
|
end
|
186
|
-
it { expect { run }.
|
294
|
+
it { expect { run }.to raise_error(ArgumentError, /You have named both your main application and your Jenkins application/) }
|
187
295
|
end
|
188
296
|
end
|
189
297
|
|
@@ -196,9 +304,9 @@ describe RHC::Commands::App do
|
|
196
304
|
@domain.add_application("jenkins", "jenkins-1.4")
|
197
305
|
end
|
198
306
|
it "should use existing jenkins" do
|
199
|
-
expect { run }.
|
200
|
-
expect { rest_client.find_application(@domain.id,"jenkins") }.
|
201
|
-
expect { rest_client.find_application(@domain.id,"jenkins2") }.
|
307
|
+
expect { run }.to exit_with_code(0)
|
308
|
+
expect { rest_client.find_application(@domain.id,"jenkins") }.to_not raise_error
|
309
|
+
expect { rest_client.find_application(@domain.id,"jenkins2") }.to raise_error(RHC::Rest::ApplicationNotFoundException)
|
202
310
|
end
|
203
311
|
end
|
204
312
|
end
|
@@ -261,7 +369,7 @@ describe RHC::Commands::App do
|
|
261
369
|
before(:each) do
|
262
370
|
@domain = rest_client.add_domain("mockdomain")
|
263
371
|
@instance.stub(:git_clone_application) { raise RHC::GitException }
|
264
|
-
@instance.
|
372
|
+
@instance.stub(:check_sshkeys!)
|
265
373
|
end
|
266
374
|
|
267
375
|
context 'when run with error in git clone' do
|
@@ -324,7 +432,7 @@ describe RHC::Commands::App do
|
|
324
432
|
end
|
325
433
|
|
326
434
|
context 'when run' do
|
327
|
-
it { expect { run }.
|
435
|
+
it { expect { run }.to exit_with_code(0) }
|
328
436
|
end
|
329
437
|
end
|
330
438
|
|
@@ -335,34 +443,34 @@ describe RHC::Commands::App do
|
|
335
443
|
before{ @domain = rest_client.add_domain("mockdomain") }
|
336
444
|
|
337
445
|
it "should raise cartridge not found exception when no apps exist" do
|
338
|
-
expect { run }.
|
446
|
+
expect { run }.to raise_error RHC::Rest::ApplicationNotFoundException
|
339
447
|
end
|
340
448
|
|
341
449
|
context "with an app" do
|
342
450
|
before{ @app = @domain.add_application("app1", "mock_type") }
|
343
451
|
|
344
452
|
it "should not remove app when no is sent as input" do
|
345
|
-
expect { run(["no"]) }.
|
453
|
+
expect { run(["no"]) }.to raise_error(RHC::ConfirmationError)
|
346
454
|
@domain.applications.length.should == 1
|
347
455
|
@domain.applications[0] == @app
|
348
456
|
end
|
349
457
|
|
350
458
|
it "should remove app when yes is sent as input" do
|
351
|
-
expect { run(["yes"]) }.
|
459
|
+
expect { run(["yes"]) }.to exit_with_code(0)
|
352
460
|
@domain.applications.length.should == 0
|
353
461
|
end
|
354
462
|
|
355
463
|
context "with --noprompt but without --confirm" do
|
356
464
|
let(:arguments) { ['app', 'delete', 'app1', '--noprompt', '--trace'] }
|
357
465
|
it "should not remove the app" do
|
358
|
-
expect { run(["no"]) }.
|
466
|
+
expect { run(["no"]) }.to raise_error(RHC::ConfirmationError)
|
359
467
|
@domain.applications.length.should == 1
|
360
468
|
end
|
361
469
|
end
|
362
470
|
context "with --noprompt and --confirm" do
|
363
471
|
let(:arguments) { ['app', 'delete', 'app1', '--noprompt', '--confirm'] }
|
364
472
|
it "should remove the app" do
|
365
|
-
expect { run }.
|
473
|
+
expect { run }.to exit_with_code(0)
|
366
474
|
@domain.applications.length.should == 0
|
367
475
|
end
|
368
476
|
end
|
@@ -445,7 +553,7 @@ describe RHC::Commands::App do
|
|
445
553
|
Kernel.should_receive(:system).with("ssh fakeuuidfortestsapp1@127.0.0.1").and_return(0)
|
446
554
|
end
|
447
555
|
it { run_output.should match("Connecting to fakeuuidfortestsapp") }
|
448
|
-
it { expect { run }.
|
556
|
+
it { expect { run }.to exit_with_code(0) }
|
449
557
|
end
|
450
558
|
end
|
451
559
|
|
@@ -459,7 +567,7 @@ describe RHC::Commands::App do
|
|
459
567
|
@instance.should_receive(:has_ssh?).and_return(false)
|
460
568
|
end
|
461
569
|
it { run_output.should match("Please use the --ssh option to specify the path to your SSH executable, or install SSH.") }
|
462
|
-
it { expect { run }.
|
570
|
+
it { expect { run }.to exit_with_code(1) }
|
463
571
|
end
|
464
572
|
end
|
465
573
|
|
@@ -474,7 +582,7 @@ describe RHC::Commands::App do
|
|
474
582
|
Kernel.should_receive(:system).with("path_to_ssh fakeuuidfortestsapp1@127.0.0.1").and_return(1)
|
475
583
|
end
|
476
584
|
it { run_output.should match("Connecting to fakeuuidfortestsapp") }
|
477
|
-
it { expect { run }.
|
585
|
+
it { expect { run }.to exit_with_code(1) }
|
478
586
|
end
|
479
587
|
end
|
480
588
|
|
@@ -496,7 +604,7 @@ describe RHC::Commands::App do
|
|
496
604
|
@domain.add_application("app1", "mock_type")
|
497
605
|
end
|
498
606
|
it { run_output.should match("started") }
|
499
|
-
it { run_output.should match("deprecated") }
|
607
|
+
it("should warn about deprecation") { run_output.should match("deprecated") }
|
500
608
|
end
|
501
609
|
end
|
502
610
|
|
@@ -10,7 +10,7 @@ describe RHC::Commands::Apps do
|
|
10
10
|
context 'when no domains' do
|
11
11
|
let(:arguments) { ['apps'] }
|
12
12
|
|
13
|
-
it { expect { run }.
|
13
|
+
it { expect { run }.to exit_with_code(1) }
|
14
14
|
it { run_output.should match(/In order to deploy applications.*rhc domain create/) }
|
15
15
|
end
|
16
16
|
|
@@ -18,21 +18,21 @@ describe RHC::Commands::Apps do
|
|
18
18
|
let(:arguments){ ['apps'] }
|
19
19
|
let!(:domain){ rest_client.add_domain("first") }
|
20
20
|
|
21
|
-
it { expect { run }.
|
21
|
+
it { expect { run }.to exit_with_code(1) }
|
22
22
|
it { run_output.should match(/No applications.*rhc app create/) }
|
23
23
|
|
24
24
|
context 'with apps' do
|
25
25
|
let(:arguments) { ['apps'] }
|
26
26
|
before{ domain.add_application('scaled', 'php', true) }
|
27
27
|
|
28
|
-
it { expect { run }.
|
28
|
+
it { expect { run }.to exit_with_code(0) }
|
29
29
|
it { run_output.should match(/scaled.*\-\-.*php.*Scaling:.*x2 \(minimum/m) }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'when help is shown' do
|
34
34
|
let(:arguments) { ['apps', '--help'] }
|
35
|
-
it { expect { run }.
|
35
|
+
it { expect { run }.to exit_with_code(0) }
|
36
36
|
it { run_output.should match(/rhc apps.*Display the list of applications/m) }
|
37
37
|
end
|
38
38
|
end
|
@@ -23,7 +23,7 @@ describe RHC::Commands::Authorization do
|
|
23
23
|
context "without authorizations" do
|
24
24
|
without_authorization
|
25
25
|
it('should warn that the server doesn\'t support auth'){ run_output.should =~ /The server does not support setting, retrieving, or authenticating with authorization tokens/ }
|
26
|
-
it{ expect{ run }.
|
26
|
+
it{ expect{ run }.to exit_with_code(1) }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -37,7 +37,7 @@ describe RHC::Commands::Authorization do
|
|
37
37
|
it('should display the expiration') { run_output.should =~ /Expires In:\s+1 minute/ }
|
38
38
|
it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date('2013-02-21T01:00:01Z')}/ }
|
39
39
|
it('should display the scopes') { run_output.should =~ /Scopes:\s+session read/ }
|
40
|
-
it{ expect{ run }.
|
40
|
+
it{ expect{ run }.to exit_with_code(0) }
|
41
41
|
end
|
42
42
|
|
43
43
|
expect_an_unsupported_message
|
@@ -47,7 +47,7 @@ describe RHC::Commands::Authorization do
|
|
47
47
|
let(:arguments) { ['authorization', '--h']}
|
48
48
|
context 'given --h' do
|
49
49
|
it 'should not raise SystemStackError' do
|
50
|
-
expect{ run }.
|
50
|
+
expect{ run }.to_not raise_error(SystemStackError)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -60,7 +60,7 @@ describe RHC::Commands::Authorization do
|
|
60
60
|
before{ stub_delete_authorization('foo') }
|
61
61
|
before{ stub_delete_authorization('bar') }
|
62
62
|
it('should display success') { run_output.should =~ /Deleting auth.*done/ }
|
63
|
-
it{ expect{ run }.
|
63
|
+
it{ expect{ run }.to exit_with_code(0) }
|
64
64
|
after{ a_request(:delete, mock_href('broker/rest/user/authorizations/foo', true)).should have_been_made }
|
65
65
|
after{ a_request(:delete, mock_href('broker/rest/user/authorizations/bar', true)).should have_been_made }
|
66
66
|
end
|
@@ -68,7 +68,7 @@ describe RHC::Commands::Authorization do
|
|
68
68
|
context "without a token in the command line" do
|
69
69
|
let(:arguments) { ['authorization', 'delete'] }
|
70
70
|
it('should display success') { run_output.should =~ /You must specify one or more tokens to delete/ }
|
71
|
-
it{ expect{ run }.
|
71
|
+
it{ expect{ run }.to exit_with_code(1) }
|
72
72
|
end
|
73
73
|
|
74
74
|
expect_an_unsupported_message
|
@@ -81,7 +81,7 @@ describe RHC::Commands::Authorization do
|
|
81
81
|
with_authorization
|
82
82
|
before{ stub_delete_authorizations }
|
83
83
|
it('should display success') { run_output.should =~ /Deleting all auth.*done/ }
|
84
|
-
it{ expect{ run }.
|
84
|
+
it{ expect{ run }.to exit_with_code(0) }
|
85
85
|
after{ a_request(:delete, mock_href('broker/rest/user/authorizations', true)).should have_been_made }
|
86
86
|
end
|
87
87
|
|
@@ -105,7 +105,7 @@ describe RHC::Commands::Authorization do
|
|
105
105
|
before{ instance.should_receive(:scope_help) }
|
106
106
|
|
107
107
|
it('should display the scope help') { command_output.should =~ /When adding an authorization.*to see more options/m }
|
108
|
-
it{ expect{ run_command }.
|
108
|
+
it{ expect{ run_command }.to exit_with_code(0) }
|
109
109
|
end
|
110
110
|
|
111
111
|
expect_an_unsupported_message
|
@@ -121,7 +121,7 @@ describe RHC::Commands::Authorization do
|
|
121
121
|
it('should display the expiration') { run_output.should =~ /Expires In:\s+5 minutes/ }
|
122
122
|
it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date(mock_date_1)}/ }
|
123
123
|
it('should display the scopes') { run_output.should =~ /Scopes:\s+foo bar/ }
|
124
|
-
it{ expect{ run }.
|
124
|
+
it{ expect{ run }.to exit_with_code(0) }
|
125
125
|
|
126
126
|
expect_an_unsupported_message
|
127
127
|
end
|
@@ -6,7 +6,7 @@ require 'rhc/config'
|
|
6
6
|
describe RHC::Commands::Cartridge do
|
7
7
|
|
8
8
|
def exit_with_code_and_message(code, message = nil)
|
9
|
-
expect{ run }.
|
9
|
+
expect{ run }.to exit_with_code(code)
|
10
10
|
run_output.should match(message) if message
|
11
11
|
end
|
12
12
|
|
@@ -50,7 +50,7 @@ describe RHC::Commands::Cartridge do
|
|
50
50
|
it{ run_output.should match /mock_standalone_cart\-2\s+web/ }
|
51
51
|
it{ run_output.should match /mock_embedded_cart\-1\s+Mock1 Embedded Cart\s+addon/ }
|
52
52
|
it{ run_output.should match /premium_cart\-1 \(\*\)\s+Premium Cart\s+web/ }
|
53
|
-
it{ expect{ run }.
|
53
|
+
it{ expect{ run }.to exit_with_code(0) }
|
54
54
|
|
55
55
|
context 'with verbose list' do
|
56
56
|
let(:arguments){ ['cartridge', 'list', '--verbose'] }
|
@@ -200,12 +200,12 @@ describe RHC::Commands::Cartridge do
|
|
200
200
|
end
|
201
201
|
it "should remove cartridge" do
|
202
202
|
@app.add_cartridge('mock_cart-1')
|
203
|
-
expect { run }.
|
203
|
+
expect { run }.to exit_with_code(0)
|
204
204
|
# framework cart should be the only one listed
|
205
205
|
@app.cartridges.length.should == 1
|
206
206
|
end
|
207
207
|
it "should raise cartridge not found exception" do
|
208
|
-
expect { run }.
|
208
|
+
expect { run }.to raise_error RHC::CartridgeNotFoundException
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
@@ -398,7 +398,7 @@ describe RHC::Commands::Cartridge do
|
|
398
398
|
end
|
399
399
|
|
400
400
|
describe 'cartridge storage' do
|
401
|
-
let!(:rest_client){ MockRestClient.new }
|
401
|
+
let!(:rest_client){ MockRestClient.new(RHC::Config, 1.3) }
|
402
402
|
let(:cmd_base) { ['cartridge', 'storage'] }
|
403
403
|
let(:std_args) { ['-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] | (@extra_args || []) }
|
404
404
|
let(:cart_type) { ['mock_cart-1'] }
|
@@ -411,10 +411,8 @@ describe RHC::Commands::Cartridge do
|
|
411
411
|
|
412
412
|
context 'when run with no arguments' do
|
413
413
|
let(:arguments) { cmd_base | std_args }
|
414
|
-
it "should show
|
415
|
-
|
416
|
-
run_output.should match('mock_cart-1')
|
417
|
-
end
|
414
|
+
it ("should show the mock_type"){ run_output.should match('mock_type') }
|
415
|
+
it ('should show mock_cart-1'){ run_output.should match('mock_cart-1') }
|
418
416
|
end
|
419
417
|
|
420
418
|
context 'when run for a non-existent cartridge' do
|
@@ -483,5 +481,16 @@ describe RHC::Commands::Cartridge do
|
|
483
481
|
fail_with_message("The amount format must be a number, optionally followed by 'GB'")
|
484
482
|
end
|
485
483
|
end
|
484
|
+
|
485
|
+
context 'when run against an outdated broker' do
|
486
|
+
before { rest_client.stub(:api_version_negotiated).and_return(1.2) }
|
487
|
+
let(:arguments) { cmd_base | cart_type | std_args }
|
488
|
+
|
489
|
+
it 'adding storage should raise a version error' do
|
490
|
+
@extra_args = ["--add", "1GB"]
|
491
|
+
fail_with_message('The server does not support this command \(requires 1.3, found 1.2\).')
|
492
|
+
end
|
493
|
+
|
494
|
+
end
|
486
495
|
end
|
487
496
|
end
|