shelly 0.0.43 → 0.0.44.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/lib/shelly/app.rb +4 -0
- data/lib/shelly/cli/backup.rb +42 -43
- data/lib/shelly/cli/config.rb +34 -47
- data/lib/shelly/cli/deploys.rb +14 -22
- data/lib/shelly/cli/main.rb +95 -88
- data/lib/shelly/cli/runner.rb +6 -2
- data/lib/shelly/cli/user.rb +10 -16
- data/lib/shelly/client.rb +36 -32
- data/lib/shelly/download_progress_bar.rb +1 -1
- data/lib/shelly/helpers.rb +5 -10
- data/lib/shelly/user.rb +10 -2
- data/lib/shelly/version.rb +1 -1
- data/lib/thor/thor.rb +4 -0
- data/shelly.gemspec +2 -1
- data/spec/helpers.rb +7 -0
- data/spec/shelly/app_spec.rb +11 -5
- data/spec/shelly/cli/backup_spec.rb +36 -31
- data/spec/shelly/cli/config_spec.rb +70 -35
- data/spec/shelly/cli/deploys_spec.rb +19 -19
- data/spec/shelly/cli/main_spec.rb +213 -105
- data/spec/shelly/cli/runner_spec.rb +29 -1
- data/spec/shelly/cli/user_spec.rb +20 -53
- data/spec/shelly/client_spec.rb +90 -81
- data/spec/shelly/download_progress_bar_spec.rb +4 -4
- data/spec/shelly/user_spec.rb +23 -0
- data/spec/spec_helper.rb +5 -1
- metadata +43 -32
@@ -18,19 +18,19 @@ describe Shelly::CLI::Backup do
|
|
18
18
|
before do
|
19
19
|
FileUtils.mkdir_p("/projects/foo")
|
20
20
|
Dir.chdir("/projects/foo")
|
21
|
-
File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\n") }
|
21
|
+
File.open("Cloudfile", 'w') { |f| f.write("foo-staging:\n") }
|
22
22
|
end
|
23
23
|
|
24
|
-
it "should
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
it "should ensure user has logged in" do
|
25
|
+
hooks(@backup, :list).should include(:logged_in?)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should ensure that Cloudfile is present" do
|
29
|
+
hooks(@backup, :list).should include(:cloudfile_present?)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should exit if user doesn't have access to cloud in Cloudfile" do
|
33
|
-
exception = Shelly::Client::
|
33
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "cloud")
|
34
34
|
@client.stub(:database_backups).and_raise(exception)
|
35
35
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
|
36
36
|
lambda { invoke(@backup, :list) }.should raise_error(SystemExit)
|
@@ -42,8 +42,8 @@ describe Shelly::CLI::Backup do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should show information to select specific cloud and exit" do
|
45
|
-
$stdout.should_receive(:puts).with("You have multiple clouds in Cloudfile.
|
46
|
-
$stdout.should_receive(:puts).with("
|
45
|
+
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
|
46
|
+
$stdout.should_receive(:puts).with("Select cloud using `shelly backup list --cloud foo-production`")
|
47
47
|
$stdout.should_receive(:puts).with("Available clouds:")
|
48
48
|
$stdout.should_receive(:puts).with(" * foo-production")
|
49
49
|
$stdout.should_receive(:puts).with(" * foo-staging")
|
@@ -71,6 +71,10 @@ describe Shelly::CLI::Backup do
|
|
71
71
|
$stdout.stub(:puts)
|
72
72
|
end
|
73
73
|
|
74
|
+
it "should ensure user has logged in" do
|
75
|
+
hooks(@backup, :get).should include(:logged_in?)
|
76
|
+
end
|
77
|
+
|
74
78
|
it "should make sure that cloud is choosen" do
|
75
79
|
@client.should_receive(:database_backup).with("foo-staging", "last")
|
76
80
|
invoke(@backup, :get)
|
@@ -103,23 +107,23 @@ describe Shelly::CLI::Backup do
|
|
103
107
|
|
104
108
|
context "on backup not found" do
|
105
109
|
it "it should display error message" do
|
106
|
-
exception = Shelly::Client::
|
110
|
+
exception = Shelly::Client::NotFoundException.new({"resource" => "database_backup"})
|
107
111
|
@client.stub(:database_backup).and_raise(exception)
|
108
112
|
$stdout.should_receive(:puts).with(red "Backup not found")
|
109
|
-
$stdout.should_receive(:puts).with("You can list available backups with
|
113
|
+
$stdout.should_receive(:puts).with("You can list available backups with `shelly backup list` command")
|
110
114
|
invoke(@backup, :get, "better.tar.gz")
|
111
115
|
end
|
112
116
|
end
|
113
117
|
|
114
118
|
context "on unsupported exception" do
|
115
119
|
it "should re-raise it" do
|
116
|
-
exception = Shelly::Client::
|
120
|
+
exception = Shelly::Client::APIException.new
|
117
121
|
@client.stub(:database_backup).and_raise(exception)
|
118
122
|
$stdout.should_not_receive(:puts).with(red "Backup not found")
|
119
|
-
$stdout.should_not_receive(:puts).with("You can list available backups with
|
123
|
+
$stdout.should_not_receive(:puts).with("You can list available backups with `shelly backup list` command")
|
120
124
|
lambda {
|
121
125
|
invoke(@backup, :get, "better.tar.gz")
|
122
|
-
}.should raise_error(Shelly::Client::
|
126
|
+
}.should raise_error(Shelly::Client::APIException)
|
123
127
|
end
|
124
128
|
end
|
125
129
|
end
|
@@ -132,8 +136,12 @@ describe Shelly::CLI::Backup do
|
|
132
136
|
File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\n") }
|
133
137
|
end
|
134
138
|
|
139
|
+
it "should ensure user has logged in" do
|
140
|
+
hooks(@backup, :create).should include(:logged_in?)
|
141
|
+
end
|
142
|
+
|
135
143
|
it "should exit if user doesn't have access to cloud in Cloudfile" do
|
136
|
-
exception = Shelly::Client::
|
144
|
+
exception = Shelly::Client::NotFoundException.new({"resource" => "cloud"})
|
137
145
|
@client.stub(:request_backup).and_raise(exception)
|
138
146
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
|
139
147
|
lambda { invoke(@backup, :create) }.should raise_error(SystemExit)
|
@@ -141,7 +149,7 @@ describe Shelly::CLI::Backup do
|
|
141
149
|
|
142
150
|
it "should display errors and exit 1 when kind is not valid" do
|
143
151
|
response = {"message" => "Wrong KIND argument. User one of following: postgresql, mongodb, redis"}
|
144
|
-
exception = Shelly::Client::
|
152
|
+
exception = Shelly::Client::ValidationException.new(response)
|
145
153
|
@client.should_receive(:request_backup).and_raise(exception)
|
146
154
|
$stdout.should_receive(:puts).with(red response["message"])
|
147
155
|
lambda { invoke(@backup, :create) }.should raise_error(SystemExit)
|
@@ -162,16 +170,20 @@ describe Shelly::CLI::Backup do
|
|
162
170
|
$stdout.stub(:puts)
|
163
171
|
end
|
164
172
|
|
173
|
+
it "should ensure user has logged in" do
|
174
|
+
hooks(@backup, :restore).should include(:logged_in?)
|
175
|
+
end
|
176
|
+
|
165
177
|
it "should restore database" do
|
166
178
|
$stdout.should_receive(:puts).with("You are about restore database postgre for cloud foo-staging to state from better.tar.gz")
|
167
179
|
$stdout.should_receive(:print).with("I want to restore the database (yes/no): ")
|
168
180
|
$stdout.should_receive(:puts).with("\n")
|
169
181
|
@client.stub(:restore_backup).with("todo-list-test","better.tar.gz")
|
170
182
|
$stdout.should_receive(:puts).with("\n")
|
171
|
-
$stdout.should_receive(:puts).with("Restore has been scheduled. Wait few minutes till database is restored.")
|
183
|
+
$stdout.should_receive(:puts).with("Restore has been scheduled. Wait a few minutes till database is restored.")
|
172
184
|
|
173
185
|
fake_stdin(["yes"]) do
|
174
|
-
@backup
|
186
|
+
invoke(@backup, :restore, "better.tar.gz")
|
175
187
|
end
|
176
188
|
end
|
177
189
|
|
@@ -184,27 +196,20 @@ describe Shelly::CLI::Backup do
|
|
184
196
|
|
185
197
|
lambda {
|
186
198
|
fake_stdin(["no"]) do
|
187
|
-
@backup
|
199
|
+
invoke(@backup, :restore, "better.tar.gz")
|
188
200
|
end
|
189
201
|
}.should raise_error(SystemExit)
|
190
202
|
end
|
191
203
|
end
|
192
204
|
|
193
|
-
it "should exit with 1 when filename is not specified" do
|
194
|
-
$stdout.should_receive(:puts).with(red "Filename is required")
|
195
|
-
lambda {
|
196
|
-
@backup.restore
|
197
|
-
}.should raise_error(SystemExit)
|
198
|
-
end
|
199
|
-
|
200
205
|
context "on backup not found" do
|
201
206
|
it "should display error message" do
|
202
|
-
response = {"
|
203
|
-
exception = Shelly::Client::
|
207
|
+
response = {"resource" => "database_backup"}
|
208
|
+
exception = Shelly::Client::NotFoundException.new(response)
|
204
209
|
@client.stub(:database_backup).and_raise(exception)
|
205
210
|
$stdout.should_receive(:puts).with(red "Backup not found")
|
206
|
-
$stdout.should_receive(:puts).with("You can list available backups with
|
207
|
-
@backup
|
211
|
+
$stdout.should_receive(:puts).with("You can list available backups with `shelly backup list` command")
|
212
|
+
invoke(@backup, :restore, "better.tar.gz")
|
208
213
|
end
|
209
214
|
end
|
210
215
|
end
|
@@ -25,17 +25,16 @@ describe Shelly::CLI::Config do
|
|
25
25
|
File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\nfoo-production:\n") }
|
26
26
|
end
|
27
27
|
|
28
|
-
it "should
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
it "should ensure user has logged in" do
|
29
|
+
hooks(@config, :list).should include(:logged_in?)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should ensure that Cloudfile is present" do
|
33
|
+
hooks(@config, :list).should include(:cloudfile_present?)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should exit if user doesn't have access to cloud in Cloudfile" do
|
37
|
-
|
38
|
-
exception = Shelly::Client::APIError.new(404, response)
|
37
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "cloud")
|
39
38
|
@client.stub(:app_configs).and_raise(exception)
|
40
39
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-production' cloud defined in Cloudfile")
|
41
40
|
lambda { invoke(@config, :list) }.should raise_error(SystemExit)
|
@@ -58,10 +57,13 @@ describe Shelly::CLI::Config do
|
|
58
57
|
end
|
59
58
|
|
60
59
|
describe "#show" do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
|
61
|
+
it "should ensure user has logged in" do
|
62
|
+
hooks(@config, :show).should include(:logged_in?)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should ensure that Cloudfile is present" do
|
66
|
+
hooks(@config, :show).should include(:cloudfile_present?)
|
65
67
|
end
|
66
68
|
|
67
69
|
it "should exit if no path was specified" do
|
@@ -79,7 +81,7 @@ describe Shelly::CLI::Config do
|
|
79
81
|
describe "on failure" do
|
80
82
|
context "when config doesn't exist" do
|
81
83
|
it "should display error message and exit with 1" do
|
82
|
-
exception = Shelly::Client::
|
84
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "config")
|
83
85
|
@client.should_receive(:app_config).and_raise(exception)
|
84
86
|
$stdout.should_receive(:puts).with(red "Config 'config/app.yml' not found")
|
85
87
|
$stdout.should_receive(:puts).with(red "You can list available config files with `shelly config list --cloud foo-staging`")
|
@@ -91,7 +93,7 @@ describe Shelly::CLI::Config do
|
|
91
93
|
|
92
94
|
context "when user doesn't have access to cloud" do
|
93
95
|
it "should display error message and exit with 1" do
|
94
|
-
exception = Shelly::Client::
|
96
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "cloud")
|
95
97
|
@client.should_receive(:app_config).and_raise(exception)
|
96
98
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
|
97
99
|
lambda {
|
@@ -107,7 +109,8 @@ describe Shelly::CLI::Config do
|
|
107
109
|
end
|
108
110
|
|
109
111
|
it "should show info to select cloud and exit" do
|
110
|
-
$stdout.should_receive(:puts).with("You have multiple clouds in Cloudfile.
|
112
|
+
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
|
113
|
+
$stdout.should_receive(:puts).with("Select cloud using `shelly show path --cloud foo-production`")
|
111
114
|
lambda { invoke(@config, :show, "path") }.should raise_error(SystemExit)
|
112
115
|
end
|
113
116
|
|
@@ -120,10 +123,12 @@ describe Shelly::CLI::Config do
|
|
120
123
|
end
|
121
124
|
|
122
125
|
describe "#create" do
|
123
|
-
it "should
|
124
|
-
|
125
|
-
|
126
|
-
|
126
|
+
it "should ensure user has logged in" do
|
127
|
+
hooks(@config, :create).should include(:logged_in?)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should ensure that Cloudfile is present" do
|
131
|
+
hooks(@config, :create).should include(:cloudfile_present?)
|
127
132
|
end
|
128
133
|
|
129
134
|
it "should exit if no path was specified" do
|
@@ -144,6 +149,18 @@ describe Shelly::CLI::Config do
|
|
144
149
|
invoke(@config, :create, "path")
|
145
150
|
end
|
146
151
|
|
152
|
+
context "on validation errors" do
|
153
|
+
it "should display validation errors" do
|
154
|
+
exception = Shelly::Client::ValidationException.new({"errors" => [["path", "is already taken"]]})
|
155
|
+
@config.should_receive(:system).with(/vim \/tmp\/shelly-edit/).and_return(true)
|
156
|
+
@client.stub(:app_create_config).and_raise(exception)
|
157
|
+
$stdout.should_receive(:puts).with(red "Path is already taken")
|
158
|
+
lambda {
|
159
|
+
invoke(@config, :create, "config/app.yml")
|
160
|
+
}.should raise_error(SystemExit)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
147
164
|
context "multiple clouds" do
|
148
165
|
before do
|
149
166
|
File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\nfoo-production:\n") }
|
@@ -151,7 +168,8 @@ describe Shelly::CLI::Config do
|
|
151
168
|
|
152
169
|
it "should show info to select cloud and exit" do
|
153
170
|
@config.stub(:system) {true}
|
154
|
-
$stdout.should_receive(:puts).with("You have multiple clouds in Cloudfile.
|
171
|
+
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
|
172
|
+
$stdout.should_receive(:puts).with("Select cloud using `shelly create path --cloud foo-production`")
|
155
173
|
lambda { @config.create("path") }.should raise_error(SystemExit)
|
156
174
|
end
|
157
175
|
|
@@ -166,10 +184,12 @@ describe Shelly::CLI::Config do
|
|
166
184
|
|
167
185
|
|
168
186
|
describe "#edit" do
|
169
|
-
it "should
|
170
|
-
|
171
|
-
|
172
|
-
|
187
|
+
it "should ensure user has logged in" do
|
188
|
+
hooks(@config, :edit).should include(:logged_in?)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should ensure that Cloudfile is present" do
|
192
|
+
hooks(@config, :edit).should include(:cloudfile_present?)
|
173
193
|
end
|
174
194
|
|
175
195
|
it "should exit if no path was specified" do
|
@@ -195,7 +215,7 @@ describe Shelly::CLI::Config do
|
|
195
215
|
describe "on failure" do
|
196
216
|
context "when config doesn't exist" do
|
197
217
|
it "should display error message and exit with 1" do
|
198
|
-
exception = Shelly::Client::
|
218
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "config")
|
199
219
|
@client.should_receive(:app_config).and_raise(exception)
|
200
220
|
$stdout.should_receive(:puts).with(red "Config 'config/app.yml' not found")
|
201
221
|
$stdout.should_receive(:puts).with(red "You can list available config files with `shelly config list --cloud foo-staging`")
|
@@ -207,7 +227,7 @@ describe Shelly::CLI::Config do
|
|
207
227
|
|
208
228
|
context "when user doesn't have access to cloud" do
|
209
229
|
it "should display error message and exit with 1" do
|
210
|
-
exception = Shelly::Client::
|
230
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "cloud")
|
211
231
|
@client.should_receive(:app_config).and_raise(exception)
|
212
232
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
|
213
233
|
lambda {
|
@@ -215,6 +235,17 @@ describe Shelly::CLI::Config do
|
|
215
235
|
}.should raise_error(SystemExit)
|
216
236
|
end
|
217
237
|
end
|
238
|
+
|
239
|
+
context "on validation errors" do
|
240
|
+
it "should display validation errors" do
|
241
|
+
exception = Shelly::Client::ValidationException.new({"errors" => [["path", "is already taken"]]})
|
242
|
+
@client.should_receive(:app_config).and_raise(exception)
|
243
|
+
$stdout.should_receive(:puts).with(red "Path is already taken")
|
244
|
+
lambda {
|
245
|
+
invoke(@config, :edit, "config/app.yml")
|
246
|
+
}.should raise_error(SystemExit)
|
247
|
+
end
|
248
|
+
end
|
218
249
|
end
|
219
250
|
|
220
251
|
context "multiple clouds" do
|
@@ -224,7 +255,8 @@ describe Shelly::CLI::Config do
|
|
224
255
|
|
225
256
|
it "should show info to select cloud and exit" do
|
226
257
|
@config.stub(:system) {true}
|
227
|
-
$stdout.should_receive(:puts).with("You have multiple clouds in Cloudfile.
|
258
|
+
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
|
259
|
+
$stdout.should_receive(:puts).with("Select cloud using `shelly edit path --cloud foo-production`")
|
228
260
|
lambda { invoke(@config, :edit, "path") }.should raise_error(SystemExit)
|
229
261
|
end
|
230
262
|
|
@@ -239,10 +271,12 @@ describe Shelly::CLI::Config do
|
|
239
271
|
end
|
240
272
|
|
241
273
|
describe "#delete" do
|
242
|
-
it "should
|
243
|
-
|
244
|
-
|
245
|
-
|
274
|
+
it "should ensure user has logged in" do
|
275
|
+
hooks(@config, :delete).should include(:logged_in?)
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should ensure that Cloudfile is present" do
|
279
|
+
hooks(@config, :delete).should include(:cloudfile_present?)
|
246
280
|
end
|
247
281
|
|
248
282
|
it "should exit if no path was specified" do
|
@@ -272,7 +306,8 @@ describe Shelly::CLI::Config do
|
|
272
306
|
end
|
273
307
|
|
274
308
|
it "should show info to select cloud and exit" do
|
275
|
-
$stdout.should_receive(:puts).with("You have multiple clouds in Cloudfile.
|
309
|
+
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
|
310
|
+
$stdout.should_receive(:puts).with("Select cloud using `shelly delete path --cloud foo-production`")
|
276
311
|
lambda { invoke(@config, :delete, "path") }.should raise_error(SystemExit)
|
277
312
|
end
|
278
313
|
|
@@ -289,7 +324,7 @@ describe Shelly::CLI::Config do
|
|
289
324
|
describe "on failure" do
|
290
325
|
context "when config doesn't exist" do
|
291
326
|
it "should display error message and exit with 1" do
|
292
|
-
exception = Shelly::Client::
|
327
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "config")
|
293
328
|
@client.should_receive(:app_delete_config).and_raise(exception)
|
294
329
|
$stdout.should_receive(:puts).with(red "Config 'config/app.yml' not found")
|
295
330
|
$stdout.should_receive(:puts).with(red "You can list available config files with `shelly config list --cloud foo-staging`")
|
@@ -303,7 +338,7 @@ describe Shelly::CLI::Config do
|
|
303
338
|
|
304
339
|
context "when user doesn't have access to cloud" do
|
305
340
|
it "should display error message and exit with 1" do
|
306
|
-
exception = Shelly::Client::
|
341
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "cloud")
|
307
342
|
@client.should_receive(:app_delete_config).and_raise(exception)
|
308
343
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
|
309
344
|
fake_stdin(["y"]) do
|
@@ -316,4 +351,4 @@ describe Shelly::CLI::Config do
|
|
316
351
|
end
|
317
352
|
|
318
353
|
end
|
319
|
-
end
|
354
|
+
end
|
@@ -20,16 +20,16 @@ describe Shelly::CLI::Deploys do
|
|
20
20
|
@client.stub(:token).and_return("abc")
|
21
21
|
end
|
22
22
|
|
23
|
-
it "should
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
it "should ensure user has logged in" do
|
24
|
+
hooks(@deploys, :list).should include(:logged_in?)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should ensure that Cloudfile is present" do
|
28
|
+
hooks(@deploys, :list).should include(:cloudfile_present?)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should exit if user doesn't have access to cloud in Cloudfile" do
|
32
|
-
@client.stub(:deploy_logs).and_raise(Shelly::Client::
|
32
|
+
@client.stub(:deploy_logs).and_raise(Shelly::Client::NotFoundException.new("resource" => "cloud"))
|
33
33
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
|
34
34
|
lambda { invoke(@deploys, :list) }.should raise_error(SystemExit)
|
35
35
|
end
|
@@ -40,8 +40,8 @@ describe Shelly::CLI::Deploys do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should show information to select specific cloud and exit" do
|
43
|
-
$stdout.should_receive(:puts).with("You have multiple clouds in Cloudfile.
|
44
|
-
$stdout.should_receive(:puts).with("
|
43
|
+
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
|
44
|
+
$stdout.should_receive(:puts).with("Select cloud using `shelly deploys list --cloud foo-production`")
|
45
45
|
$stdout.should_receive(:puts).with("Available clouds:")
|
46
46
|
$stdout.should_receive(:puts).with(" * foo-production")
|
47
47
|
$stdout.should_receive(:puts).with(" * foo-staging")
|
@@ -78,17 +78,17 @@ describe Shelly::CLI::Deploys do
|
|
78
78
|
@client.stub(:token).and_return("abc")
|
79
79
|
end
|
80
80
|
|
81
|
-
it "should
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
it "should ensure user has logged in" do
|
82
|
+
hooks(@deploys, :show).should include(:logged_in?)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should ensure that Cloudfile is present" do
|
86
|
+
hooks(@deploys, :show).should include(:cloudfile_present?)
|
87
87
|
end
|
88
88
|
|
89
89
|
context "user doesn't have access to cloud" do
|
90
90
|
it "should exit 1 with message" do
|
91
|
-
exception = Shelly::Client::
|
91
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "cloud")
|
92
92
|
@client.stub(:deploy_log).and_raise(exception)
|
93
93
|
$stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
|
94
94
|
lambda { @deploys.show("last") }.should raise_error(SystemExit)
|
@@ -97,7 +97,7 @@ describe Shelly::CLI::Deploys do
|
|
97
97
|
|
98
98
|
context "log not found" do
|
99
99
|
it "should exit 1 with message" do
|
100
|
-
exception = Shelly::Client::
|
100
|
+
exception = Shelly::Client::NotFoundException.new("resource" => "log")
|
101
101
|
@client.stub(:deploy_log).and_raise(exception)
|
102
102
|
$stdout.should_receive(:puts).with(red "Log not found, list all deploy logs using `shelly deploys list --cloud=foo-staging`")
|
103
103
|
lambda { @deploys.show("last") }.should raise_error(SystemExit)
|
@@ -110,8 +110,8 @@ describe Shelly::CLI::Deploys do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should show information to select specific cloud and exit" do
|
113
|
-
$stdout.should_receive(:puts).with("You have multiple clouds in Cloudfile.
|
114
|
-
$stdout.should_receive(:puts).with("
|
113
|
+
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
|
114
|
+
$stdout.should_receive(:puts).with("Select cloud using `shelly deploys show last --cloud foo-production`")
|
115
115
|
$stdout.should_receive(:puts).with("Available clouds:")
|
116
116
|
$stdout.should_receive(:puts).with(" * foo-production")
|
117
117
|
$stdout.should_receive(:puts).with(" * foo-staging")
|