pogo 2.31.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +73 -0
- data/bin/pogo +22 -0
- data/data/cacert.pem +3988 -0
- data/lib/heroku.rb +22 -0
- data/lib/heroku/auth.rb +320 -0
- data/lib/heroku/cli.rb +38 -0
- data/lib/heroku/client.rb +764 -0
- data/lib/heroku/client/heroku_postgresql.rb +111 -0
- data/lib/heroku/client/pgbackups.rb +113 -0
- data/lib/heroku/client/rendezvous.rb +105 -0
- data/lib/heroku/client/ssl_endpoint.rb +25 -0
- data/lib/heroku/command.rb +273 -0
- data/lib/heroku/command/account.rb +23 -0
- data/lib/heroku/command/accounts.rb +34 -0
- data/lib/heroku/command/addons.rb +305 -0
- data/lib/heroku/command/apps.rb +311 -0
- data/lib/heroku/command/auth.rb +86 -0
- data/lib/heroku/command/base.rb +230 -0
- data/lib/heroku/command/certs.rb +148 -0
- data/lib/heroku/command/config.rb +137 -0
- data/lib/heroku/command/db.rb +218 -0
- data/lib/heroku/command/domains.rb +85 -0
- data/lib/heroku/command/drains.rb +46 -0
- data/lib/heroku/command/git.rb +65 -0
- data/lib/heroku/command/help.rb +163 -0
- data/lib/heroku/command/keys.rb +115 -0
- data/lib/heroku/command/labs.rb +161 -0
- data/lib/heroku/command/logs.rb +98 -0
- data/lib/heroku/command/maintenance.rb +61 -0
- data/lib/heroku/command/pg.rb +277 -0
- data/lib/heroku/command/pgbackups.rb +289 -0
- data/lib/heroku/command/plugins.rb +110 -0
- data/lib/heroku/command/ps.rb +232 -0
- data/lib/heroku/command/releases.rb +124 -0
- data/lib/heroku/command/run.rb +179 -0
- data/lib/heroku/command/sharing.rb +89 -0
- data/lib/heroku/command/ssl.rb +61 -0
- data/lib/heroku/command/stack.rb +62 -0
- data/lib/heroku/command/status.rb +51 -0
- data/lib/heroku/command/update.rb +47 -0
- data/lib/heroku/command/version.rb +23 -0
- data/lib/heroku/deprecated.rb +5 -0
- data/lib/heroku/deprecated/help.rb +38 -0
- data/lib/heroku/distribution.rb +9 -0
- data/lib/heroku/helpers.rb +517 -0
- data/lib/heroku/helpers/heroku_postgresql.rb +104 -0
- data/lib/heroku/plugin.rb +161 -0
- data/lib/heroku/updater.rb +158 -0
- data/lib/heroku/version.rb +3 -0
- data/lib/vendor/heroku/okjson.rb +598 -0
- data/spec/helper/legacy_help.rb +16 -0
- data/spec/heroku/auth_spec.rb +246 -0
- data/spec/heroku/client/heroku_postgresql_spec.rb +34 -0
- data/spec/heroku/client/pgbackups_spec.rb +43 -0
- data/spec/heroku/client/rendezvous_spec.rb +62 -0
- data/spec/heroku/client/ssl_endpoint_spec.rb +48 -0
- data/spec/heroku/client_spec.rb +564 -0
- data/spec/heroku/command/addons_spec.rb +585 -0
- data/spec/heroku/command/apps_spec.rb +351 -0
- data/spec/heroku/command/auth_spec.rb +38 -0
- data/spec/heroku/command/base_spec.rb +109 -0
- data/spec/heroku/command/certs_spec.rb +178 -0
- data/spec/heroku/command/config_spec.rb +144 -0
- data/spec/heroku/command/db_spec.rb +110 -0
- data/spec/heroku/command/domains_spec.rb +87 -0
- data/spec/heroku/command/drains_spec.rb +34 -0
- data/spec/heroku/command/git_spec.rb +116 -0
- data/spec/heroku/command/help_spec.rb +93 -0
- data/spec/heroku/command/keys_spec.rb +120 -0
- data/spec/heroku/command/labs_spec.rb +99 -0
- data/spec/heroku/command/logs_spec.rb +60 -0
- data/spec/heroku/command/maintenance_spec.rb +51 -0
- data/spec/heroku/command/pg_spec.rb +223 -0
- data/spec/heroku/command/pgbackups_spec.rb +280 -0
- data/spec/heroku/command/plugins_spec.rb +104 -0
- data/spec/heroku/command/ps_spec.rb +195 -0
- data/spec/heroku/command/releases_spec.rb +130 -0
- data/spec/heroku/command/run_spec.rb +86 -0
- data/spec/heroku/command/sharing_spec.rb +59 -0
- data/spec/heroku/command/ssl_spec.rb +32 -0
- data/spec/heroku/command/stack_spec.rb +46 -0
- data/spec/heroku/command/status_spec.rb +48 -0
- data/spec/heroku/command/version_spec.rb +16 -0
- data/spec/heroku/command_spec.rb +211 -0
- data/spec/heroku/helpers/heroku_postgresql_spec.rb +109 -0
- data/spec/heroku/helpers_spec.rb +48 -0
- data/spec/heroku/plugin_spec.rb +172 -0
- data/spec/heroku/updater_spec.rb +44 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +209 -0
- data/spec/support/display_message_matcher.rb +49 -0
- data/spec/support/openssl_mock_helper.rb +8 -0
- metadata +220 -0
@@ -0,0 +1,351 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "heroku/command/apps"
|
3
|
+
|
4
|
+
module Heroku::Command
|
5
|
+
describe Apps do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
stub_core
|
9
|
+
end
|
10
|
+
|
11
|
+
context("info") do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
api.post_app("name" => "myapp", "stack" => "cedar")
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:each) do
|
18
|
+
api.delete_app("myapp")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "displays impicit app info" do
|
22
|
+
stderr, stdout = execute("apps:info")
|
23
|
+
stderr.should == ""
|
24
|
+
stdout.should == <<-STDOUT
|
25
|
+
=== myapp
|
26
|
+
Git URL: git@heroku.com:myapp.git
|
27
|
+
Owner Email: email@example.com
|
28
|
+
Stack: cedar
|
29
|
+
Web URL: http://myapp.herokuapp.com/
|
30
|
+
STDOUT
|
31
|
+
end
|
32
|
+
|
33
|
+
it "gets explicit app from --app" do
|
34
|
+
stderr, stdout = execute("apps:info --app myapp")
|
35
|
+
stderr.should == ""
|
36
|
+
stdout.should == <<-STDOUT
|
37
|
+
=== myapp
|
38
|
+
Git URL: git@heroku.com:myapp.git
|
39
|
+
Owner Email: email@example.com
|
40
|
+
Stack: cedar
|
41
|
+
Web URL: http://myapp.herokuapp.com/
|
42
|
+
STDOUT
|
43
|
+
end
|
44
|
+
|
45
|
+
it "shows shell app info when --shell option is used" do
|
46
|
+
stderr, stdout = execute("apps:info --shell")
|
47
|
+
stderr.should == ""
|
48
|
+
stdout.should match Regexp.new(<<-STDOUT)
|
49
|
+
create_status=complete
|
50
|
+
created_at=\\d{4}/\\d{2}/\\d{2} \\d{2}:\\d{2}:\\d{2} [+-]\\d{4}
|
51
|
+
dynos=0
|
52
|
+
git_url=git@heroku.com:myapp.git
|
53
|
+
id=\\d{1,5}
|
54
|
+
name=myapp
|
55
|
+
owner_email=email@example.com
|
56
|
+
repo_migrate_status=complete
|
57
|
+
repo_size=
|
58
|
+
requested_stack=
|
59
|
+
slug_size=
|
60
|
+
stack=cedar
|
61
|
+
web_url=http://myapp.herokuapp.com/
|
62
|
+
workers=0
|
63
|
+
STDOUT
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
context("create") do
|
69
|
+
|
70
|
+
it "without a name" do
|
71
|
+
name = nil
|
72
|
+
with_blank_git_repository do
|
73
|
+
stderr, stdout = execute("apps:create")
|
74
|
+
name = api.get_apps.body.first["name"]
|
75
|
+
stderr.should == ""
|
76
|
+
stdout.should == <<-STDOUT
|
77
|
+
Creating #{name}... done, stack is bamboo-mri-1.9.2
|
78
|
+
http://#{name}.herokuapp.com/ | git@heroku.com:#{name}.git
|
79
|
+
Git remote heroku added
|
80
|
+
STDOUT
|
81
|
+
end
|
82
|
+
api.delete_app(name)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "with a name" do
|
86
|
+
with_blank_git_repository do
|
87
|
+
stderr, stdout = execute("apps:create myapp")
|
88
|
+
stderr.should == ""
|
89
|
+
stdout.should == <<-STDOUT
|
90
|
+
Creating myapp... done, stack is bamboo-mri-1.9.2
|
91
|
+
http://myapp.herokuapp.com/ | git@heroku.com:myapp.git
|
92
|
+
Git remote heroku added
|
93
|
+
STDOUT
|
94
|
+
end
|
95
|
+
api.delete_app("myapp")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "with -a name" do
|
99
|
+
with_blank_git_repository do
|
100
|
+
stderr, stdout = execute("apps:create -a myapp")
|
101
|
+
stderr.should == ""
|
102
|
+
stdout.should == <<-STDOUT
|
103
|
+
Creating myapp... done, stack is bamboo-mri-1.9.2
|
104
|
+
http://myapp.herokuapp.com/ | git@heroku.com:myapp.git
|
105
|
+
Git remote heroku added
|
106
|
+
STDOUT
|
107
|
+
end
|
108
|
+
api.delete_app("myapp")
|
109
|
+
end
|
110
|
+
|
111
|
+
it "with --no-remote" do
|
112
|
+
with_blank_git_repository do
|
113
|
+
stderr, stdout = execute("apps:create myapp --no-remote")
|
114
|
+
stderr.should == ""
|
115
|
+
stdout.should == <<-STDOUT
|
116
|
+
Creating myapp... done, stack is bamboo-mri-1.9.2
|
117
|
+
http://myapp.herokuapp.com/ | git@heroku.com:myapp.git
|
118
|
+
STDOUT
|
119
|
+
end
|
120
|
+
api.delete_app("myapp")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "with addons" do
|
124
|
+
with_blank_git_repository do
|
125
|
+
stderr, stdout = execute("apps:create addonapp --addon custom_domains:basic,releases:basic")
|
126
|
+
stderr.should == ""
|
127
|
+
stdout.should == <<-STDOUT
|
128
|
+
Creating addonapp... done, stack is bamboo-mri-1.9.2
|
129
|
+
Adding custom_domains:basic to addonapp... done
|
130
|
+
Adding releases:basic to addonapp... done
|
131
|
+
http://addonapp.herokuapp.com/ | git@heroku.com:addonapp.git
|
132
|
+
Git remote heroku added
|
133
|
+
STDOUT
|
134
|
+
end
|
135
|
+
api.delete_app("addonapp")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "with a buildpack" do
|
139
|
+
with_blank_git_repository do
|
140
|
+
stderr, stdout = execute("apps:create buildpackapp --buildpack http://example.org/buildpack.git")
|
141
|
+
stderr.should == ""
|
142
|
+
stdout.should == <<-STDOUT
|
143
|
+
Creating buildpackapp... done, stack is bamboo-mri-1.9.2
|
144
|
+
BUILDPACK_URL=http://example.org/buildpack.git
|
145
|
+
http://buildpackapp.herokuapp.com/ | git@heroku.com:buildpackapp.git
|
146
|
+
Git remote heroku added
|
147
|
+
STDOUT
|
148
|
+
end
|
149
|
+
api.delete_app("buildpackapp")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "with an alternate remote name" do
|
153
|
+
with_blank_git_repository do
|
154
|
+
stderr, stdout = execute("apps:create alternate-remote --remote alternate")
|
155
|
+
stderr.should == ""
|
156
|
+
stdout.should == <<-STDOUT
|
157
|
+
Creating alternate-remote... done, stack is bamboo-mri-1.9.2
|
158
|
+
http://alternate-remote.herokuapp.com/ | git@heroku.com:alternate-remote.git
|
159
|
+
Git remote alternate added
|
160
|
+
STDOUT
|
161
|
+
end
|
162
|
+
api.delete_app("alternate-remote")
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
context("index") do
|
168
|
+
|
169
|
+
before(:each) do
|
170
|
+
api.post_app("name" => "myapp", "stack" => "cedar")
|
171
|
+
end
|
172
|
+
|
173
|
+
after(:each) do
|
174
|
+
api.delete_app("myapp")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "succeeds" do
|
178
|
+
stub_core.list.returns([["myapp", "user"]])
|
179
|
+
stderr, stdout = execute("apps")
|
180
|
+
stderr.should == ""
|
181
|
+
stdout.should == <<-STDOUT
|
182
|
+
=== My Apps
|
183
|
+
myapp
|
184
|
+
|
185
|
+
STDOUT
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
context("rename") do
|
191
|
+
|
192
|
+
context("success") do
|
193
|
+
|
194
|
+
before(:each) do
|
195
|
+
api.post_app("name" => "myapp", "stack" => "cedar")
|
196
|
+
end
|
197
|
+
|
198
|
+
after(:each) do
|
199
|
+
api.delete_app("myapp2")
|
200
|
+
end
|
201
|
+
|
202
|
+
it "renames app" do
|
203
|
+
with_blank_git_repository do
|
204
|
+
stderr, stdout = execute("apps:rename myapp2")
|
205
|
+
stderr.should == ""
|
206
|
+
stdout.should == <<-STDOUT
|
207
|
+
Renaming myapp to myapp2... done
|
208
|
+
http://myapp2.herokuapp.com/ | git@heroku.com:myapp2.git
|
209
|
+
Don't forget to update your Git remotes on any local checkouts.
|
210
|
+
STDOUT
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
it "displays an error if no name is specified" do
|
217
|
+
stderr, stdout = execute("apps:rename")
|
218
|
+
stderr.should == <<-STDERR
|
219
|
+
! Usage: heroku apps:rename NEWNAME
|
220
|
+
! Must specify NEWNAME to rename.
|
221
|
+
STDERR
|
222
|
+
stdout.should == ""
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
context("destroy") do
|
228
|
+
|
229
|
+
before(:each) do
|
230
|
+
api.post_app("name" => "myapp", "stack" => "cedar")
|
231
|
+
end
|
232
|
+
|
233
|
+
it "succeeds with app explicitly specified with --app and user confirmation" do
|
234
|
+
stderr, stdout = execute("apps:destroy --confirm myapp")
|
235
|
+
stderr.should == ""
|
236
|
+
stdout.should == <<-STDOUT
|
237
|
+
Destroying myapp (including all add-ons)... done
|
238
|
+
STDOUT
|
239
|
+
end
|
240
|
+
|
241
|
+
context("fails") do
|
242
|
+
|
243
|
+
after(:each) do
|
244
|
+
api.delete_app("myapp")
|
245
|
+
end
|
246
|
+
|
247
|
+
it "fails with explicit app but no confirmation" do
|
248
|
+
stderr, stdout = execute("apps:destroy myapp")
|
249
|
+
stderr.should == <<-STDERR
|
250
|
+
! Confirmation did not match myapp. Aborted.
|
251
|
+
STDERR
|
252
|
+
stdout.should == "
|
253
|
+
! WARNING: Potentially Destructive Action
|
254
|
+
! This command will destroy myapp (including all add-ons).
|
255
|
+
! To proceed, type \"myapp\" or re-run this command with --confirm myapp
|
256
|
+
|
257
|
+
> "
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
it "fails without explicit app" do
|
262
|
+
stderr, stdout = execute("apps:destroy")
|
263
|
+
stderr.should == <<-STDERR
|
264
|
+
! Usage: heroku apps:destroy --app APP
|
265
|
+
! Must specify APP to destroy.
|
266
|
+
STDERR
|
267
|
+
stdout.should == ""
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
context "Git Integration" do
|
275
|
+
|
276
|
+
it "creates adding heroku to git remote" do
|
277
|
+
with_blank_git_repository do
|
278
|
+
stderr, stdout = execute("apps:create myapp")
|
279
|
+
stderr.should == ""
|
280
|
+
stdout.should == <<-STDOUT
|
281
|
+
Creating myapp... done, stack is bamboo-mri-1.9.2
|
282
|
+
http://myapp.herokuapp.com/ | git@heroku.com:myapp.git
|
283
|
+
Git remote heroku added
|
284
|
+
STDOUT
|
285
|
+
`git remote`.strip.should match(/^heroku$/)
|
286
|
+
api.delete_app("myapp")
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
it "creates adding a custom git remote" do
|
291
|
+
with_blank_git_repository do
|
292
|
+
stderr, stdout = execute("apps:create myapp --remote myremote")
|
293
|
+
stderr.should == ""
|
294
|
+
stdout.should == <<-STDOUT
|
295
|
+
Creating myapp... done, stack is bamboo-mri-1.9.2
|
296
|
+
http://myapp.herokuapp.com/ | git@heroku.com:myapp.git
|
297
|
+
Git remote myremote added
|
298
|
+
STDOUT
|
299
|
+
`git remote`.strip.should match(/^myremote$/)
|
300
|
+
api.delete_app("myapp")
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
it "doesn't add a git remote if it already exists" do
|
305
|
+
with_blank_git_repository do
|
306
|
+
`git remote add heroku /tmp/git_spec_#{Process.pid}`
|
307
|
+
stderr, stdout = execute("apps:create myapp")
|
308
|
+
stderr.should == ""
|
309
|
+
stdout.should == <<-STDOUT
|
310
|
+
Creating myapp... done, stack is bamboo-mri-1.9.2
|
311
|
+
http://myapp.herokuapp.com/ | git@heroku.com:myapp.git
|
312
|
+
STDOUT
|
313
|
+
api.delete_app("myapp")
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
it "renames updating the corresponding heroku git remote" do
|
318
|
+
with_blank_git_repository do
|
319
|
+
`git remote add github git@github.com:test/test.git`
|
320
|
+
`git remote add production git@heroku.com:myapp.git`
|
321
|
+
`git remote add staging git@heroku.com:myapp-staging.git`
|
322
|
+
|
323
|
+
api.post_app("name" => "myapp", "stack" => "cedar")
|
324
|
+
stderr, stdout = execute("apps:rename myapp2")
|
325
|
+
api.delete_app("myapp2")
|
326
|
+
|
327
|
+
remotes = `git remote -v`
|
328
|
+
remotes.should == <<-REMOTES
|
329
|
+
github\tgit@github.com:test/test.git (fetch)
|
330
|
+
github\tgit@github.com:test/test.git (push)
|
331
|
+
production\tgit@heroku.com:myapp2.git (fetch)
|
332
|
+
production\tgit@heroku.com:myapp2.git (push)
|
333
|
+
staging\tgit@heroku.com:myapp-staging.git (fetch)
|
334
|
+
staging\tgit@heroku.com:myapp-staging.git (push)
|
335
|
+
REMOTES
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
it "destroys removing any remotes pointing to the app" do
|
340
|
+
with_blank_git_repository do
|
341
|
+
`git remote add heroku git@heroku.com:myapp.git`
|
342
|
+
|
343
|
+
api.post_app("name" => "myapp", "stack" => "cedar")
|
344
|
+
stderr, stdout = execute("apps:destroy --confirm myapp")
|
345
|
+
|
346
|
+
`git remote`.strip.should_not include('heroku')
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "heroku/command/auth"
|
3
|
+
|
4
|
+
describe Heroku::Command::Auth do
|
5
|
+
describe "auth" do
|
6
|
+
it "displays heroku help auth" do
|
7
|
+
stderr, stdout = execute("auth")
|
8
|
+
|
9
|
+
stderr.should == ""
|
10
|
+
stdout.should include "Additional commands"
|
11
|
+
stdout.should include "auth:login"
|
12
|
+
stdout.should include "auth:logout"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "auth:token" do
|
17
|
+
|
18
|
+
it "displays the user's api key" do
|
19
|
+
stderr, stdout = execute("auth:token")
|
20
|
+
stderr.should == ""
|
21
|
+
stdout.should == <<-STDOUT
|
22
|
+
apikey01
|
23
|
+
STDOUT
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "auth:whoami" do
|
28
|
+
it "displays the user's email address" do
|
29
|
+
stderr, stdout = execute("auth:whoami")
|
30
|
+
stderr.should == ""
|
31
|
+
stdout.should == <<-STDOUT
|
32
|
+
email@example.com
|
33
|
+
STDOUT
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "heroku/command/base"
|
3
|
+
|
4
|
+
module Heroku::Command
|
5
|
+
describe Base do
|
6
|
+
before do
|
7
|
+
@base = Base.new
|
8
|
+
@base.stub!(:display)
|
9
|
+
@client = mock('heroku client', :host => 'heroku.com')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "confirming" do
|
13
|
+
it "confirms the app via --confirm" do
|
14
|
+
Heroku::Command.stub(:current_options).and_return(:confirm => "myapp")
|
15
|
+
@base.stub(:app).and_return("myapp")
|
16
|
+
@base.confirm_command.should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "does not confirms the app via --confirm on a mismatch" do
|
20
|
+
Heroku::Command.stub(:current_options).and_return(:confirm => "badapp")
|
21
|
+
@base.stub(:app).and_return("myapp")
|
22
|
+
lambda { @base.confirm_command}.should raise_error CommandFailed
|
23
|
+
end
|
24
|
+
|
25
|
+
it "confirms the app interactively via ask" do
|
26
|
+
@base.stub(:app).and_return("myapp")
|
27
|
+
@base.stub(:ask).and_return("myapp")
|
28
|
+
Heroku::Command.stub(:current_options).and_return({})
|
29
|
+
@base.confirm_command.should be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "fails if the interactive confirm doesn't match" do
|
33
|
+
@base.stub(:app).and_return("myapp")
|
34
|
+
@base.stub(:ask).and_return("badresponse")
|
35
|
+
Heroku::Command.stub(:current_options).and_return({})
|
36
|
+
capture_stderr do
|
37
|
+
lambda { @base.confirm_command }.should raise_error(SystemExit)
|
38
|
+
end.should == <<-STDERR
|
39
|
+
! Confirmation did not match myapp. Aborted.
|
40
|
+
STDERR
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "detecting the app" do
|
45
|
+
it "attempts to find the app via the --app option" do
|
46
|
+
@base.stub!(:options).and_return(:app => "myapp")
|
47
|
+
@base.app.should == "myapp"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "attempts to find the app via the --confirm option" do
|
51
|
+
@base.stub!(:options).and_return(:confirm => "myconfirmapp")
|
52
|
+
@base.app.should == "myconfirmapp"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "attempts to find the app via HEROKU_APP when not explicitly specified" do
|
56
|
+
ENV['HEROKU_APP'] = "myenvapp"
|
57
|
+
@base.app.should == "myenvapp"
|
58
|
+
@base.stub!(:options).and_return([])
|
59
|
+
@base.app.should == "myenvapp"
|
60
|
+
ENV.delete('HEROKU_APP')
|
61
|
+
end
|
62
|
+
|
63
|
+
it "overrides HEROKU_APP when explicitly specified" do
|
64
|
+
ENV['HEROKU_APP'] = "myenvapp"
|
65
|
+
@base.stub!(:options).and_return(:app => "myapp")
|
66
|
+
@base.app.should == "myapp"
|
67
|
+
ENV.delete('HEROKU_APP')
|
68
|
+
end
|
69
|
+
|
70
|
+
it "read remotes from git config" do
|
71
|
+
Dir.stub(:chdir)
|
72
|
+
File.should_receive(:exists?).with(".git").and_return(true)
|
73
|
+
@base.should_receive(:git).with('remote -v').and_return(<<-REMOTES)
|
74
|
+
staging\tgit@heroku.com:myapp-staging.git (fetch)
|
75
|
+
staging\tgit@heroku.com:myapp-staging.git (push)
|
76
|
+
production\tgit@heroku.com:myapp.git (fetch)
|
77
|
+
production\tgit@heroku.com:myapp.git (push)
|
78
|
+
other\tgit@other.com:other.git (fetch)
|
79
|
+
other\tgit@other.com:other.git (push)
|
80
|
+
REMOTES
|
81
|
+
|
82
|
+
@heroku = mock
|
83
|
+
@heroku.stub(:host).and_return('heroku.com')
|
84
|
+
@base.stub(:heroku).and_return(@heroku)
|
85
|
+
|
86
|
+
# need a better way to test internal functionality
|
87
|
+
@base.send(:git_remotes, '/home/dev/myapp').should == { 'staging' => 'myapp-staging', 'production' => 'myapp' }
|
88
|
+
end
|
89
|
+
|
90
|
+
it "gets the app from remotes when there's only one app" do
|
91
|
+
@base.stub!(:git_remotes).and_return({ 'heroku' => 'myapp' })
|
92
|
+
@base.stub!(:git).with("config heroku.remote").and_return("")
|
93
|
+
@base.app.should == 'myapp'
|
94
|
+
end
|
95
|
+
|
96
|
+
it "accepts a --remote argument to choose the app from the remote name" do
|
97
|
+
@base.stub!(:git_remotes).and_return({ 'staging' => 'myapp-staging', 'production' => 'myapp' })
|
98
|
+
@base.stub!(:options).and_return(:remote => "staging")
|
99
|
+
@base.app.should == 'myapp-staging'
|
100
|
+
end
|
101
|
+
|
102
|
+
it "raises when cannot determine which app is it" do
|
103
|
+
@base.stub!(:git_remotes).and_return({ 'staging' => 'myapp-staging', 'production' => 'myapp' })
|
104
|
+
lambda { @base.app }.should raise_error(Heroku::Command::CommandFailed)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|