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,15 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe CFConsole do
|
4
4
|
before do
|
5
|
-
@app =
|
5
|
+
@app = double("app")
|
6
6
|
@console = CFConsole.new(nil, @app)
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should return connection info for apps that have a console ip and port" do
|
10
|
-
instance =
|
11
|
-
|
12
|
-
|
10
|
+
instance = double("instance")
|
11
|
+
@app.should_receive(:instances) { [instance] }
|
12
|
+
instance.should_receive(:console) { {:ip => "192.168.1.1", :port => 3344} }
|
13
13
|
|
14
14
|
@console.get_connection_info(nil).should == {
|
15
15
|
"hostname" => "192.168.1.1",
|
@@ -18,7 +18,7 @@ describe "CFConsole" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should raise error when no app instances found" do
|
21
|
-
|
21
|
+
@app.should_receive(:instances) { [] }
|
22
22
|
|
23
23
|
expect {
|
24
24
|
@console.get_connection_info(nil)
|
@@ -26,9 +26,9 @@ describe "CFConsole" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should raise error when app does not have console access" do
|
29
|
-
instance =
|
30
|
-
|
31
|
-
|
29
|
+
instance = double("instance")
|
30
|
+
@app.should_receive(:instances) { [instance] }
|
31
|
+
instance.should_receive(:console) { nil }
|
32
32
|
|
33
33
|
expect {
|
34
34
|
@console.get_connection_info(nil)
|
@@ -46,7 +46,7 @@ describe "CFConsole" do
|
|
46
46
|
|
47
47
|
context "when console credentials cannot be obtained" do
|
48
48
|
it "should raise error" do
|
49
|
-
|
49
|
+
@app.should_receive(:file).with(*@creds[:path]) { "username: cfuser" }
|
50
50
|
|
51
51
|
expect {
|
52
52
|
@console.start_console
|
@@ -56,63 +56,63 @@ describe "CFConsole" do
|
|
56
56
|
|
57
57
|
context "when console credentials can be obtained" do
|
58
58
|
before do
|
59
|
-
|
59
|
+
@app.should_receive(:file).with(*@creds[:path]) { @creds[:yaml] }
|
60
60
|
@telnet = Object.new
|
61
|
-
|
61
|
+
@console.should_receive(:telnet_client).and_return(@telnet)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should raise error if authentication fails" do
|
65
|
-
|
66
|
-
|
65
|
+
@telnet.should_receive(:login).with(@creds[:telnet]) { "Login failed" }
|
66
|
+
@telnet.should_receive(:close)
|
67
67
|
|
68
68
|
expect { @console.start_console }.to raise_error("Login failed")
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should retry authentication on timeout" do
|
72
|
-
|
73
|
-
|
72
|
+
@telnet.should_receive(:login).with(@creds[:telnet]){ raise TimeoutError }
|
73
|
+
@telnet.should_receive(:login).with(@creds[:telnet]) { "Switch to inspect mode\nirb():001:0> " }
|
74
74
|
verify_console_exit("irb():001:0> ")
|
75
75
|
|
76
76
|
@console.start_console
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should retry authentication on EOF" do
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
@console.should_receive(:telnet_client).and_return(@telnet)
|
81
|
+
@telnet.should_receive(:login).with(@creds[:telnet]) { raise EOFError }
|
82
|
+
@telnet.should_receive(:close)
|
83
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
84
84
|
verify_console_exit("irb():001:0> ")
|
85
85
|
|
86
86
|
@console.start_console
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should operate console interactively" do
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
91
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
92
|
+
Readline::HISTORY.should_receive(:push).with("puts 'hi'")
|
93
|
+
@telnet.should_receive(:cmd).with("puts 'hi'").and_return("nil" + "\n" + "irb():002:0> ")
|
94
|
+
@console.should_receive(:puts).with("nil")
|
95
95
|
verify_console_exit("irb():002:0> ")
|
96
96
|
|
97
97
|
@console.start_console
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should not crash if command times out" do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
102
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
103
|
+
Readline::HISTORY.should_receive(:push).with("puts 'hi'")
|
104
|
+
@telnet.should_receive(:cmd).with("puts 'hi'") { raise TimeoutError }
|
105
|
+
@console.should_receive(:puts).with("Timed out sending command to server.")
|
106
106
|
verify_console_exit("irb():001:0> ")
|
107
107
|
|
108
108
|
@console.start_console
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should raise error if an EOF is received" do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("Switch to inspect mode\nirb():001:0> ")
|
113
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
114
|
+
Readline::HISTORY.should_receive(:push).with("puts 'hi'")
|
115
|
+
@telnet.should_receive(:cmd).with("puts 'hi'") { raise EOFError }
|
116
116
|
|
117
117
|
expect {
|
118
118
|
@console.start_console
|
@@ -120,30 +120,30 @@ describe "CFConsole" do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should not keep blank lines in history" do
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
124
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "" }
|
125
|
+
Readline::HISTORY.should_not_receive(:push)
|
126
|
+
@telnet.should_receive(:cmd).and_return("irb():002:0*> ")
|
127
127
|
verify_console_exit("irb():002:0*> ")
|
128
128
|
|
129
129
|
@console.start_console
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should not keep identical commands in history" do
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
133
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
134
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
135
|
+
Readline::HISTORY.should_receive(:to_a).and_return(["puts 'hi'"])
|
136
|
+
Readline::HISTORY.should_not_receive(:push).with("puts 'hi'")
|
137
|
+
@telnet.should_receive(:cmd).with("puts 'hi'").and_return("nil" + "\n" + "irb():002:0> ")
|
138
|
+
@console.should_receive(:puts).with("nil")
|
139
139
|
verify_console_exit("irb():002:0> ")
|
140
140
|
|
141
141
|
@console.start_console
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should return tab completion data" do
|
145
|
-
|
146
|
-
|
145
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("Switch to inspect mode\nirb():001:0> ")
|
146
|
+
@telnet.should_receive(:cmd).with("String" => "app.\t", "Match" => /\S*\n$/, "Timeout" => 10) { "to_s,nil?\n" }
|
147
147
|
verify_console_exit("irb():001:0> ")
|
148
148
|
|
149
149
|
@console.start_console
|
@@ -151,8 +151,8 @@ describe "CFConsole" do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should return tab completion data receiving empty completion string" do
|
154
|
-
|
155
|
-
|
154
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
155
|
+
@telnet.should_receive(:cmd).with("String" => "app.\t", "Match" => /\S*\n$/, "Timeout" => 10) { "\n" }
|
156
156
|
verify_console_exit("irb():001:0> ")
|
157
157
|
|
158
158
|
@console.start_console
|
@@ -160,8 +160,8 @@ describe "CFConsole" do
|
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should not crash on timeout of remote tab completion data" do
|
163
|
-
|
164
|
-
|
163
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("Switch to inspect mode\nirb():001:0> ")
|
164
|
+
@telnet.should_receive(:cmd).with("String" => "app.\t", "Match" => /\S*\n$/, "Timeout" => 10) { raise TimeoutError }
|
165
165
|
verify_console_exit("irb():001:0> ")
|
166
166
|
|
167
167
|
@console.start_console
|
@@ -169,11 +169,11 @@ describe "CFConsole" do
|
|
169
169
|
end
|
170
170
|
|
171
171
|
it "should properly initialize Readline for tab completion" do
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
172
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
173
|
+
Readline.should_receive(:respond_to?).with("basic_word_break_characters=") { true }
|
174
|
+
Readline.should_receive(:basic_word_break_characters=).with(" \t\n`><=;|&{(")
|
175
|
+
Readline.should_receive(:completion_append_character=).with(nil)
|
176
|
+
Readline.should_receive(:completion_proc=).with(anything)
|
177
177
|
verify_console_exit("irb():001:0> ")
|
178
178
|
|
179
179
|
@console.start_console
|
@@ -182,8 +182,8 @@ describe "CFConsole" do
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def verify_console_exit(prompt)
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
Readline.should_receive(:readline).with(prompt) { "exit" }
|
186
|
+
@telnet.should_receive(:cmd).with("String" => "exit", "Timeout" => 1) { raise TimeoutError }
|
187
|
+
@telnet.should_receive(:close)
|
188
188
|
end
|
189
189
|
end
|
data/spec/features/org_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
if ENV['CF_V2_RUN_INTEGRATION']
|
3
|
+
if ENV["CF_V2_RUN_INTEGRATION"]
|
5
4
|
describe "creating and deleting orgs", :ruby19 => true do
|
6
5
|
before(:all) do
|
7
6
|
WebMock.allow_net_connect!
|
@@ -11,11 +10,11 @@ if ENV['CF_V2_RUN_INTEGRATION']
|
|
11
10
|
WebMock.disable_net_connect!
|
12
11
|
end
|
13
12
|
|
14
|
-
let(:target) { ENV[
|
15
|
-
let(:organization) { ENV[
|
16
|
-
let(:space) { ENV[
|
17
|
-
let(:username) { ENV[
|
18
|
-
let(:password) { ENV[
|
13
|
+
let(:target) { ENV["CF_V2_TEST_TARGET"] }
|
14
|
+
let(:organization) { ENV["CF_V2_TEST_ORGANIZATION"] }
|
15
|
+
let(:space) { ENV["CF_V2_TEST_SPACE"] }
|
16
|
+
let(:username) { ENV["CF_V2_ADMIN_USERNAME"] }
|
17
|
+
let(:password) { ENV["CF_V2_ADMIN_PW"] }
|
19
18
|
|
20
19
|
let(:run_id) { TRAVIS_BUILD_ID.to_s + Time.new.to_f.to_s.gsub(".", "_") }
|
21
20
|
let(:new_org_name) { "new-org-#{run_id}" }
|
@@ -47,9 +46,10 @@ if ENV['CF_V2_RUN_INTEGRATION']
|
|
47
46
|
runner.should say "Creating space new-space... OK"
|
48
47
|
end
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
# pending until cc change 442f08e72c0808baf85b948a8b56e58f025edf72 is on a1
|
50
|
+
#BlueShell::Runner.run("cf delete-org #{new_org_name} --force") do |runner|
|
51
|
+
# runner.should say "If you want to delete the organization along with all dependent objects, rerun the command with the '--recursive' flag."
|
52
|
+
#end
|
53
53
|
|
54
54
|
BlueShell::Runner.run("cf delete-org #{new_org_name} --force --recursive") do |runner|
|
55
55
|
runner.should say("Deleting organization #{new_org_name}... OK")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe CFManifests do
|
4
4
|
let(:inputs_hash) { {} }
|
@@ -9,7 +9,7 @@ describe CFManifests do
|
|
9
9
|
let(:cmd) do
|
10
10
|
manifest = CF::App::Push.new(nil, inputs)
|
11
11
|
manifest.extend CFManifests
|
12
|
-
stub(
|
12
|
+
manifest.stub(:client) { client }
|
13
13
|
manifest
|
14
14
|
end
|
15
15
|
|
@@ -28,22 +28,22 @@ describe CFManifests do
|
|
28
28
|
let(:manifest_file) { "/abc/manifest.yml" }
|
29
29
|
|
30
30
|
before do
|
31
|
-
stub(
|
31
|
+
cmd.stub(:target_base) { target_base }
|
32
32
|
|
33
|
-
stub(
|
34
|
-
stub(
|
33
|
+
cmd.stub(:manifest) { manifest }
|
34
|
+
cmd.stub(:manifest_file) { manifest_file }
|
35
35
|
end
|
36
36
|
|
37
|
-
describe
|
37
|
+
describe "#find_apps" do
|
38
38
|
subject { cmd.find_apps(nil) }
|
39
39
|
|
40
|
-
context
|
41
|
-
before { stub(
|
40
|
+
context "when there is no manifest file" do
|
41
|
+
before { cmd.stub(:manifest).and_return(nil) }
|
42
42
|
it { should eq [] }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
46
|
+
describe "#create_manifest_for" do
|
47
47
|
let(:app) {
|
48
48
|
fake :app,
|
49
49
|
:memory => 2048,
|
@@ -105,7 +105,7 @@ describe CFManifests do
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
context
|
108
|
+
context "when there is no url" do
|
109
109
|
let(:app) {
|
110
110
|
fake :app,
|
111
111
|
:memory => 2048,
|
@@ -115,7 +115,7 @@ describe CFManifests do
|
|
115
115
|
its(["url"]) { should eq "none" }
|
116
116
|
end
|
117
117
|
|
118
|
-
context
|
118
|
+
context "when there is no command" do
|
119
119
|
let(:app) {
|
120
120
|
fake :app,
|
121
121
|
:memory => 2048,
|
@@ -125,7 +125,7 @@ describe CFManifests do
|
|
125
125
|
it { should_not include "command" }
|
126
126
|
end
|
127
127
|
|
128
|
-
context
|
128
|
+
context "when there are no service bindings" do
|
129
129
|
let(:app) {
|
130
130
|
fake :app,
|
131
131
|
:memory => 2048,
|
@@ -174,21 +174,21 @@ describe CFManifests do
|
|
174
174
|
let(:service_bindings) { [fake(:service_binding, :service_instance => service_1)] }
|
175
175
|
|
176
176
|
it "does neither create nor bind the service again" do
|
177
|
-
|
178
|
-
|
177
|
+
cmd.should_not_receive(:invoke).with(:create_service, anything)
|
178
|
+
cmd.should_not_receive(:invoke).with(:bind_service, anything)
|
179
179
|
cmd.send(:setup_services, app, info)
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
183
|
context "but are not bound" do
|
184
184
|
it "does not create the services" do
|
185
|
-
|
186
|
-
stub(
|
185
|
+
cmd.should_not_receive(:invoke).with(:create_service, anything)
|
186
|
+
cmd.stub(:invoke).with(:bind_service, anything)
|
187
187
|
cmd.send(:setup_services, app, info)
|
188
188
|
end
|
189
189
|
|
190
190
|
it "binds the service" do
|
191
|
-
|
191
|
+
cmd.should_receive(:invoke).with(:bind_service, :app => app, :service => service_1)
|
192
192
|
cmd.send(:setup_services, app, info)
|
193
193
|
end
|
194
194
|
end
|
@@ -196,9 +196,9 @@ describe CFManifests do
|
|
196
196
|
|
197
197
|
context "and the services do not exist" do
|
198
198
|
it "creates the services" do
|
199
|
-
|
200
|
-
:name => service_1.name, :offering => mysql, :plan => plan_100
|
201
|
-
|
199
|
+
cmd.should_receive(:invoke).with(:create_service, :app => app,
|
200
|
+
:name => service_1.name, :offering => mysql, :plan => plan_100)
|
201
|
+
cmd.should_not_receive(:invoke).with(:bind_service, anything)
|
202
202
|
cmd.send(:setup_services, app, info)
|
203
203
|
end
|
204
204
|
end
|
@@ -302,7 +302,7 @@ describe CFManifests do
|
|
302
302
|
subject { cmd.current_apps }
|
303
303
|
|
304
304
|
it "returns the applications with the cwd as their path" do
|
305
|
-
stub(
|
305
|
+
Dir.stub(:pwd) { "/abc" }
|
306
306
|
expect(subject).to eq [{ :name => "foo", :path => "/abc"}, { :name => "bar", :path => "/abc" }]
|
307
307
|
end
|
308
308
|
end
|
@@ -13,14 +13,14 @@ describe ManifestsPlugin do
|
|
13
13
|
let(:client) { fake_client }
|
14
14
|
|
15
15
|
before do
|
16
|
-
stub(
|
17
|
-
stub(
|
18
|
-
stub(
|
16
|
+
plugin.stub(:manifest) { manifest }
|
17
|
+
plugin.stub(:manifest_file) { manifest_file } if manifest_file
|
18
|
+
plugin.stub(:client) { client }
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#wrap_with_optional_name" do
|
22
22
|
let(:name_made_optional) { true }
|
23
|
-
let(:wrapped) {
|
23
|
+
let(:wrapped) { double(:wrapped).as_null_object }
|
24
24
|
|
25
25
|
subject { plugin.send(:wrap_with_optional_name, name_made_optional, wrapped, inputs) }
|
26
26
|
|
@@ -28,8 +28,8 @@ describe ManifestsPlugin do
|
|
28
28
|
let(:inputs_hash) { { :all => true } }
|
29
29
|
|
30
30
|
it "skips all manifest-related logic, and invokes the command" do
|
31
|
-
|
32
|
-
|
31
|
+
wrapped.should_receive(:call)
|
32
|
+
plugin.should_not_receive(:show_manifest_usage)
|
33
33
|
subject
|
34
34
|
end
|
35
35
|
end
|
@@ -41,8 +41,8 @@ describe ManifestsPlugin do
|
|
41
41
|
let(:given_hash) { { :app => "foo" } }
|
42
42
|
|
43
43
|
it "passes through to the command" do
|
44
|
-
|
45
|
-
|
44
|
+
wrapped.should_receive(:call)
|
45
|
+
plugin.should_not_receive(:show_manifest_usage)
|
46
46
|
subject
|
47
47
|
end
|
48
48
|
end
|
@@ -52,7 +52,7 @@ describe ManifestsPlugin do
|
|
52
52
|
|
53
53
|
context "and we made it optional" do
|
54
54
|
it "fails manually" do
|
55
|
-
|
55
|
+
plugin.should_receive(:no_apps)
|
56
56
|
subject
|
57
57
|
end
|
58
58
|
end
|
@@ -61,8 +61,8 @@ describe ManifestsPlugin do
|
|
61
61
|
let(:name_made_optional) { false }
|
62
62
|
|
63
63
|
it "passes through to the command" do
|
64
|
-
|
65
|
-
|
64
|
+
wrapped.should_receive(:call)
|
65
|
+
plugin.should_not_receive(:show_manifest_usage)
|
66
66
|
subject
|
67
67
|
end
|
68
68
|
end
|
@@ -73,7 +73,7 @@ describe ManifestsPlugin do
|
|
73
73
|
let(:manifest_file) { "/abc/manifest.yml" }
|
74
74
|
|
75
75
|
before do
|
76
|
-
stub(
|
76
|
+
plugin.stub(:show_manifest_usage)
|
77
77
|
end
|
78
78
|
|
79
79
|
context "when no apps are given" do
|
@@ -81,11 +81,11 @@ describe ManifestsPlugin do
|
|
81
81
|
let(:manifest) { { :applications => [{ :name => "foo", :path => "/abc/foo" }] } }
|
82
82
|
|
83
83
|
it "calls the command for only that app" do
|
84
|
-
|
84
|
+
wrapped.should_receive(:call).with(anything) do |inputs|
|
85
85
|
expect(inputs.given[:app]).to eq "foo"
|
86
86
|
end
|
87
87
|
|
88
|
-
stub(
|
88
|
+
Dir.stub(:pwd) { "/abc/foo" }
|
89
89
|
|
90
90
|
subject
|
91
91
|
end
|
@@ -96,7 +96,7 @@ describe ManifestsPlugin do
|
|
96
96
|
|
97
97
|
it "calls the command for all apps in the manifest" do
|
98
98
|
uncalled_apps = ["foo", "bar"]
|
99
|
-
|
99
|
+
wrapped.should_receive(:call).with(anything).twice do |inputs|
|
100
100
|
uncalled_apps.delete inputs.given[:app]
|
101
101
|
end
|
102
102
|
|
@@ -114,10 +114,10 @@ describe ManifestsPlugin do
|
|
114
114
|
let(:given_hash) { { :apps => ["x", "a"] } }
|
115
115
|
|
116
116
|
it "passes through to the original command" do
|
117
|
-
|
117
|
+
plugin.should_receive(:show_manifest_usage)
|
118
118
|
|
119
119
|
uncalled_apps = ["a", "x"]
|
120
|
-
|
120
|
+
wrapped.should_receive(:call).with(anything).twice do |inputs|
|
121
121
|
uncalled_apps.delete inputs.given[:app]
|
122
122
|
end
|
123
123
|
|
@@ -136,8 +136,8 @@ describe ManifestsPlugin do
|
|
136
136
|
let(:given_hash) { { :apps => ["x", "y"] } }
|
137
137
|
|
138
138
|
it "passes through to the original command" do
|
139
|
-
|
140
|
-
|
139
|
+
wrapped.should_receive(:call)
|
140
|
+
plugin.should_not_receive(:show_manifest_usage)
|
141
141
|
subject
|
142
142
|
end
|
143
143
|
end
|
@@ -148,7 +148,7 @@ describe ManifestsPlugin do
|
|
148
148
|
let(:given_hash) { { :app => "foo" } }
|
149
149
|
|
150
150
|
it "calls the command with that app" do
|
151
|
-
|
151
|
+
wrapped.should_receive(:call).with(anything) do |inputs|
|
152
152
|
expect(inputs.given[:app]).to eq "foo"
|
153
153
|
end
|
154
154
|
|
@@ -161,7 +161,7 @@ describe ManifestsPlugin do
|
|
161
161
|
let(:given_hash) { { :app => "/abc/foo" } }
|
162
162
|
|
163
163
|
it "calls the command with that app" do
|
164
|
-
|
164
|
+
wrapped.should_receive(:call).with(anything) do |inputs|
|
165
165
|
expect(inputs.given[:app]).to eq "foo"
|
166
166
|
end
|
167
167
|
|
@@ -172,13 +172,13 @@ describe ManifestsPlugin do
|
|
172
172
|
end
|
173
173
|
|
174
174
|
describe "#wrap_push" do
|
175
|
-
let(:wrapped) {
|
175
|
+
let(:wrapped) { double(:wrapped).as_null_object }
|
176
176
|
let(:command) { Mothership.commands[:push] }
|
177
177
|
|
178
178
|
subject { plugin.send(:wrap_push, wrapped, inputs) }
|
179
179
|
|
180
180
|
before do
|
181
|
-
stub(
|
181
|
+
plugin.stub(:show_manifest_usage)
|
182
182
|
end
|
183
183
|
|
184
184
|
context "with a manifest" do
|
@@ -209,7 +209,7 @@ describe ManifestsPlugin do
|
|
209
209
|
let(:given_hash) { { :name => "a", :instances => "100" } }
|
210
210
|
|
211
211
|
it "rebases their inputs on the manifest's values" do
|
212
|
-
|
212
|
+
wrapped.should_receive(:call).with(anything) do |inputs|
|
213
213
|
expect(inputs.given).to eq(
|
214
214
|
:name => "a", :path => "/abc/a", :instances => "100", :memory => "128M")
|
215
215
|
end
|
@@ -221,7 +221,7 @@ describe ManifestsPlugin do
|
|
221
221
|
|
222
222
|
context "and the app does NOT exist" do
|
223
223
|
it "pushes a new app with the inputs from the manifest" do
|
224
|
-
|
224
|
+
wrapped.should_receive(:call).with(anything) do |inputs|
|
225
225
|
expect(inputs.given).to eq(
|
226
226
|
:name => "a", :path => "/abc/a", :instances => "200", :memory => "128M")
|
227
227
|
end
|
@@ -263,7 +263,7 @@ describe ManifestsPlugin do
|
|
263
263
|
|
264
264
|
it "pushes the found apps" do
|
265
265
|
pushed_apps = []
|
266
|
-
|
266
|
+
wrapped.should_receive(:call).with(anything).twice do |inputs|
|
267
267
|
pushed_apps << inputs[:name]
|
268
268
|
end
|
269
269
|
|
@@ -284,12 +284,12 @@ describe ManifestsPlugin do
|
|
284
284
|
end
|
285
285
|
|
286
286
|
context "without a manifest" do
|
287
|
-
let(:app) {
|
287
|
+
let(:app) { double(:app).as_null_object }
|
288
288
|
let(:manifest) { nil }
|
289
289
|
|
290
290
|
it "asks to save the manifest when uploading the application" do
|
291
291
|
mock_ask("Save configuration?", :default => false)
|
292
|
-
stub(
|
292
|
+
wrapped.stub(:call) { plugin.filter(:push_app, app) }
|
293
293
|
subject
|
294
294
|
end
|
295
295
|
end
|
@@ -298,7 +298,7 @@ describe ManifestsPlugin do
|
|
298
298
|
describe "#push_input_for" do
|
299
299
|
context "with an existing app" do
|
300
300
|
before do
|
301
|
-
stub(
|
301
|
+
plugin.stub(:from_manifest) { "PATH" }
|
302
302
|
app.changes.clear
|
303
303
|
end
|
304
304
|
|
@@ -320,14 +320,14 @@ describe ManifestsPlugin do
|
|
320
320
|
end
|
321
321
|
|
322
322
|
it "does not ask to set --reset" do
|
323
|
-
|
323
|
+
plugin.should_not_receive(:warn_reset_changes)
|
324
324
|
subject
|
325
325
|
end
|
326
326
|
end
|
327
327
|
|
328
328
|
context "without changes" do
|
329
329
|
it "does not ask to set --reset" do
|
330
|
-
|
330
|
+
plugin.should_not_receive(:warn_reset_changes)
|
331
331
|
subject
|
332
332
|
end
|
333
333
|
end
|
@@ -340,19 +340,19 @@ describe ManifestsPlugin do
|
|
340
340
|
let(:manifest_memory) { "128M" }
|
341
341
|
|
342
342
|
it "asks user to provide --reset" do
|
343
|
-
|
343
|
+
plugin.should_receive(:warn_reset_changes)
|
344
344
|
subject
|
345
345
|
end
|
346
346
|
|
347
347
|
it "does not apply changes" do
|
348
|
-
stub(
|
348
|
+
plugin.stub(:warn_reset_changes)
|
349
349
|
subject[:memory].should == nil
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
353
353
|
context "without changes" do
|
354
354
|
it "does not ask to set --reset" do
|
355
|
-
|
355
|
+
plugin.should_not_receive(:warn_reset_changes)
|
356
356
|
subject
|
357
357
|
end
|
358
358
|
end
|