kumade 0.0.3 → 0.0.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/LICENSE +19 -0
- data/README.md +15 -5
- data/features/kumade_executable.feature +9 -1
- data/features/support/env.rb +4 -0
- data/kumade.gemspec +0 -1
- data/lib/kumade.rb +4 -5
- data/lib/kumade/deployer.rb +70 -65
- data/lib/kumade/thor_task.rb +1 -1
- data/lib/kumade/version.rb +1 -1
- data/spec/kumade/deployer_spec.rb +420 -408
- data/spec/kumade_spec.rb +4 -4
- data/spec/spec_helper.rb +4 -6
- metadata +75 -70
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008 Joe Ferris and thoughtbot, inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Kumade [](http://travis-ci.org/gabebw/kumade)
|
2
2
|
Kumade is a set of basic Rake tasks for deploying to Heroku. It aims to
|
3
3
|
provide most of what you want. Unlike other Heroku deploy gems, it is
|
4
4
|
well-tested.
|
@@ -38,6 +38,10 @@ The default task is to deploy to staging:
|
|
38
38
|
|
39
39
|
$ kumade # equivalent to "kumade deploy staging"
|
40
40
|
|
41
|
+
## Does it support the Cedar stack?
|
42
|
+
|
43
|
+
Yes.
|
44
|
+
|
41
45
|
## Sample Output
|
42
46
|
|
43
47
|
### Normal mode
|
@@ -119,13 +123,19 @@ The default task is to deploy to staging:
|
|
119
123
|
==> Deploying to: origin
|
120
124
|
==> ! Cannot deploy: "origin" remote does not point to Heroku
|
121
125
|
|
122
|
-
|
123
126
|
## Compatibility
|
127
|
+
|
124
128
|
Tested against:
|
125
|
-
|
126
|
-
|
127
|
-
|
129
|
+
|
130
|
+
* MRI 1.8.7
|
131
|
+
* MRI 1.9.2
|
132
|
+
* REE 1.8.7
|
128
133
|
|
129
134
|
## What's with the name?
|
135
|
+
|
130
136
|
Kumade ([pronunciation here](http://translate.google.com/#ja|en|熊手)) means
|
131
137
|
"bamboo rake" in Japanese.
|
138
|
+
|
139
|
+
## License
|
140
|
+
|
141
|
+
kumade is Copyright © thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
@creates-remote
|
1
|
+
@extra-timeout @creates-remote
|
2
2
|
Feature: Kumade executable
|
3
3
|
As a user
|
4
4
|
I want to be able to use the kumade executable
|
@@ -18,9 +18,13 @@ Feature: Kumade executable
|
|
18
18
|
==> Git repo is clean
|
19
19
|
==> Rake passed
|
20
20
|
==> Packaged assets with Jammit
|
21
|
+
run git push origin master
|
21
22
|
==> Pushed master -> origin
|
23
|
+
run git push -f pretend-staging master
|
22
24
|
==> Force pushed master -> pretend-staging
|
25
|
+
run bundle exec heroku rake db:migrate --app pretend-staging-app
|
23
26
|
==> Migrated pretend-staging-app
|
27
|
+
run git checkout master && git branch -D deploy
|
24
28
|
==> Deployed to: pretend-staging
|
25
29
|
"""
|
26
30
|
But the output should not contain "==> Packaged assets with More"
|
@@ -33,3 +37,7 @@ Feature: Kumade executable
|
|
33
37
|
When I run `kumade deploy bamboo`
|
34
38
|
Then the output should contain "==> Deploying to: bamboo"
|
35
39
|
Then the output should match /Cannot deploy: /
|
40
|
+
|
41
|
+
Scenario: Deploying to a non-Heroku remote fails
|
42
|
+
When I run `kumade deploy origin`
|
43
|
+
Then the output should match /==> ! Cannot deploy: "origin" remote does not point to Heroku/
|
data/features/support/env.rb
CHANGED
data/kumade.gemspec
CHANGED
data/lib/kumade.rb
CHANGED
@@ -3,12 +3,11 @@ require 'kumade/thor_task'
|
|
3
3
|
|
4
4
|
module Kumade
|
5
5
|
def self.app_for(environment)
|
6
|
-
heroku_git_url = `git
|
7
|
-
|
8
|
-
|
9
|
-
match[1]
|
6
|
+
heroku_git_url = `git config --get remote.#{environment}.url`.strip
|
7
|
+
if heroku_git_url =~ /^git@heroku\.com:(.+)\.git$/
|
8
|
+
$1
|
10
9
|
else
|
11
|
-
|
10
|
+
nil
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
data/lib/kumade/deployer.rb
CHANGED
@@ -3,18 +3,12 @@ require 'rake'
|
|
3
3
|
|
4
4
|
module Kumade
|
5
5
|
class Deployer < Thor::Shell::Color
|
6
|
+
DEPLOY_BRANCH = "deploy"
|
6
7
|
attr_reader :pretending
|
7
8
|
|
8
9
|
def initialize(pretending = false)
|
9
10
|
super()
|
10
|
-
@pretending =
|
11
|
-
end
|
12
|
-
|
13
|
-
def pre_deploy
|
14
|
-
ensure_clean_git
|
15
|
-
ensure_rake_passes
|
16
|
-
package_assets
|
17
|
-
git_push('origin')
|
11
|
+
@pretending = pretending
|
18
12
|
end
|
19
13
|
|
20
14
|
def deploy_to(environment)
|
@@ -23,35 +17,57 @@ module Kumade
|
|
23
17
|
pre_deploy
|
24
18
|
git_force_push(string_environment)
|
25
19
|
heroku_migrate(string_environment)
|
20
|
+
post_deploy
|
21
|
+
end
|
22
|
+
|
23
|
+
def pre_deploy
|
24
|
+
ensure_clean_git
|
25
|
+
ensure_rake_passes
|
26
|
+
package_assets
|
27
|
+
git_push('origin')
|
26
28
|
end
|
27
29
|
|
28
30
|
def git_push(remote)
|
29
|
-
|
30
|
-
|
31
|
-
"Failed to push master -> #{remote}")
|
32
|
-
end
|
31
|
+
run_or_error("git push #{remote} master",
|
32
|
+
"Failed to push master -> #{remote}")
|
33
33
|
success("Pushed master -> #{remote}")
|
34
34
|
end
|
35
35
|
|
36
36
|
def git_force_push(remote)
|
37
|
-
|
38
|
-
|
39
|
-
"Failed to force push master -> #{remote}")
|
40
|
-
end
|
37
|
+
run_or_error("git push -f #{remote} master",
|
38
|
+
"Failed to force push master -> #{remote}")
|
41
39
|
success("Force pushed master -> #{remote}")
|
42
40
|
end
|
43
41
|
|
44
42
|
def heroku_migrate(environment)
|
45
43
|
app = Kumade.app_for(environment)
|
46
44
|
|
47
|
-
|
48
|
-
run("bundle exec heroku rake db:migrate --app #{app}")
|
49
|
-
end
|
45
|
+
heroku("rake db:migrate", app)
|
50
46
|
success("Migrated #{app}")
|
51
47
|
end
|
52
48
|
|
49
|
+
def post_deploy
|
50
|
+
run_or_error("git checkout master", "git branch -D #{DEPLOY_BRANCH}",
|
51
|
+
"Failed to clean up #{DEPLOY_BRANCH} branch")
|
52
|
+
end
|
53
|
+
|
54
|
+
def heroku(command, app)
|
55
|
+
heroku_command = if on_cedar?(app)
|
56
|
+
"bundle exec heroku run"
|
57
|
+
else
|
58
|
+
"bundle exec heroku"
|
59
|
+
end
|
60
|
+
run_or_error("#{heroku_command} #{command} --app #{app}",
|
61
|
+
"Failed to run #{command} on Heroku")
|
62
|
+
end
|
63
|
+
|
64
|
+
def on_cedar?(app)
|
65
|
+
selected_stack = `heroku stack --app '#{app}'`.split("\n").grep(/^\*/).first
|
66
|
+
selected_stack && selected_stack.include?('cedar')
|
67
|
+
end
|
68
|
+
|
53
69
|
def ensure_clean_git
|
54
|
-
if
|
70
|
+
if ! pretending && git_dirty?
|
55
71
|
error("Cannot deploy: repo is not clean.")
|
56
72
|
else
|
57
73
|
success("Git repo is clean")
|
@@ -60,7 +76,7 @@ module Kumade
|
|
60
76
|
|
61
77
|
def ensure_rake_passes
|
62
78
|
if default_task_exists?
|
63
|
-
if
|
79
|
+
if rake_succeeded?
|
64
80
|
success("Rake passed")
|
65
81
|
else
|
66
82
|
error("Cannot deploy: tests did not pass")
|
@@ -93,23 +109,27 @@ module Kumade
|
|
93
109
|
end
|
94
110
|
|
95
111
|
def package_with_more
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
112
|
+
success_message = "Packaged assets with More"
|
113
|
+
if pretending
|
114
|
+
success(success_message)
|
115
|
+
else
|
116
|
+
begin
|
117
|
+
run "bundle exec rake more:generate"
|
118
|
+
if git_dirty?
|
119
|
+
success(success_message)
|
120
|
+
git_add_and_commit_all_assets_in(more_assets_path)
|
121
|
+
end
|
122
|
+
rescue => more_error
|
123
|
+
error("Error: #{more_error.class}: #{more_error.message}")
|
102
124
|
end
|
103
|
-
rescue => more_error
|
104
|
-
error("Error: #{more_error.class}: #{more_error.message}")
|
105
125
|
end
|
106
126
|
end
|
107
127
|
|
108
128
|
def git_add_and_commit_all_assets_in(dir)
|
109
|
-
run_or_error
|
110
|
-
|
129
|
+
run_or_error "git checkout -b #{DEPLOY_BRANCH}", "git add -f #{dir}", "git commit -m 'Compiled assets'",
|
130
|
+
"Cannot deploy: couldn't commit assets"
|
111
131
|
|
112
|
-
success
|
132
|
+
success "Added and committed all assets"
|
113
133
|
end
|
114
134
|
|
115
135
|
def jammit_assets_path
|
@@ -125,6 +145,7 @@ module Kumade
|
|
125
145
|
(defined?(Jammit) ||
|
126
146
|
begin
|
127
147
|
require 'jammit'
|
148
|
+
true
|
128
149
|
rescue LoadError
|
129
150
|
false
|
130
151
|
end)
|
@@ -135,6 +156,7 @@ module Kumade
|
|
135
156
|
(defined?(Less::More) ||
|
136
157
|
begin
|
137
158
|
require 'less/more'
|
159
|
+
true
|
138
160
|
rescue LoadError
|
139
161
|
false
|
140
162
|
end)
|
@@ -145,29 +167,26 @@ module Kumade
|
|
145
167
|
end
|
146
168
|
|
147
169
|
def rake_succeeded?
|
170
|
+
return true if pretending
|
171
|
+
|
148
172
|
begin
|
149
|
-
|
173
|
+
run "bundle exec rake"
|
150
174
|
rescue
|
151
175
|
false
|
152
176
|
end
|
153
177
|
end
|
154
178
|
|
155
179
|
def git_dirty?
|
156
|
-
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
def run(command)
|
161
|
-
announce "+ #{command}"
|
162
|
-
announce "- #{system command}"
|
163
|
-
$?.success?
|
180
|
+
`git diff --exit-code`
|
181
|
+
!$?.success?
|
164
182
|
end
|
165
183
|
|
166
|
-
def run_or_error(
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
184
|
+
def run_or_error(*commands, error_message)
|
185
|
+
all_commands = commands.join(' && ')
|
186
|
+
if pretending
|
187
|
+
say_status(:run, all_commands)
|
188
|
+
else
|
189
|
+
error(error_message) unless run(all_commands)
|
171
190
|
end
|
172
191
|
end
|
173
192
|
|
@@ -184,19 +203,12 @@ module Kumade
|
|
184
203
|
say("==> #{message}", :green)
|
185
204
|
end
|
186
205
|
|
187
|
-
def string_present?(maybe_string)
|
188
|
-
maybe_string.is_a?(String) && maybe_string.size > 0
|
189
|
-
end
|
190
|
-
|
191
206
|
def ensure_heroku_remote_exists_for(environment)
|
192
207
|
if remote_exists?(environment)
|
193
|
-
if Kumade.app_for(environment)
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
else
|
198
|
-
error(%{Cannot deploy: "#{environment}" remote does not point to Heroku})
|
199
|
-
end
|
208
|
+
if app_name = Kumade.app_for(environment)
|
209
|
+
success("#{environment} is a Heroku remote")
|
210
|
+
else
|
211
|
+
error(%{Cannot deploy: "#{environment}" remote does not point to Heroku})
|
200
212
|
end
|
201
213
|
else
|
202
214
|
error(%{Cannot deploy: "#{environment}" remote does not exist})
|
@@ -207,14 +219,7 @@ module Kumade
|
|
207
219
|
if pretending
|
208
220
|
true
|
209
221
|
else
|
210
|
-
`git remote
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def initialize_rake
|
215
|
-
if Rake.application.tasks.empty?
|
216
|
-
Rake.application.options.rakelib = ['rakelib']
|
217
|
-
Rake.application.load_rakefile
|
222
|
+
`git remote` =~ /^#{remote_name}$/
|
218
223
|
end
|
219
224
|
end
|
220
225
|
end
|
data/lib/kumade/thor_task.rb
CHANGED
@@ -5,7 +5,7 @@ module Kumade
|
|
5
5
|
default_task :deploy
|
6
6
|
|
7
7
|
desc "deploy [ENV]", "Deploy to ENV (default: staging)"
|
8
|
-
method_option :pretend, :aliases => "-p", :desc => "Pretend Mode - print out what kumade would do"
|
8
|
+
method_option :pretend, :aliases => "-p", :desc => "Pretend Mode - print out what kumade would do", :default => false
|
9
9
|
def deploy(environment = 'staging')
|
10
10
|
say("==> In Pretend Mode", :red) if options[:pretend]
|
11
11
|
say "==> Deploying to: #{environment}"
|
data/lib/kumade/version.rb
CHANGED
@@ -1,586 +1,598 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'jammit'
|
3
|
-
|
4
|
-
module Kumade
|
5
|
-
describe Deployer, "#pre_deploy" do
|
6
|
-
before { subject.stub(:say) }
|
7
|
-
|
8
|
-
it "calls the correct methods in order" do
|
9
|
-
%w(
|
10
|
-
ensure_clean_git
|
11
|
-
ensure_rake_passes
|
12
|
-
package_assets
|
13
|
-
git_push
|
14
|
-
).each do |task|
|
15
|
-
subject.should_receive(task).ordered.and_return(true)
|
16
|
-
end
|
17
2
|
|
18
|
-
|
19
|
-
|
3
|
+
describe Kumade::Deployer, "#pre_deploy" do
|
4
|
+
before { subject.stub(:say) }
|
20
5
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
6
|
+
it "calls the correct methods in order" do
|
7
|
+
%w(
|
8
|
+
ensure_clean_git
|
9
|
+
ensure_rake_passes
|
10
|
+
package_assets
|
11
|
+
git_push
|
26
12
|
).each do |task|
|
27
|
-
|
28
|
-
|
13
|
+
subject.should_receive(task).ordered.and_return(true)
|
14
|
+
end
|
29
15
|
|
30
|
-
|
31
|
-
|
16
|
+
subject.pre_deploy
|
17
|
+
end
|
18
|
+
|
19
|
+
it "pushes to origin" do
|
20
|
+
%w(
|
21
|
+
ensure_clean_git
|
22
|
+
ensure_rake_passes
|
23
|
+
package_assets
|
24
|
+
).each do |task|
|
25
|
+
subject.stub(task)
|
32
26
|
end
|
27
|
+
|
28
|
+
subject.should_receive(:git_push).with('origin')
|
29
|
+
subject.pre_deploy
|
33
30
|
end
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
describe Kumade::Deployer, "#deploy_to" do
|
34
|
+
let(:remote_name){ 'staging' }
|
35
|
+
let(:app_name){ 'kumade-staging' }
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
before do
|
38
|
+
subject.stub(:say)
|
39
|
+
force_add_heroku_remote(remote_name, app_name)
|
40
|
+
end
|
43
41
|
|
44
|
-
|
42
|
+
after { remove_remote(remote_name) }
|
45
43
|
|
46
|
-
|
47
|
-
|
44
|
+
it "calls the correct methods in order" do
|
45
|
+
subject.stub(:run => true)
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
subject.should_receive(:ensure_heroku_remote_exists_for).
|
48
|
+
ordered.
|
49
|
+
with(remote_name)
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
subject.should_receive(:pre_deploy).
|
52
|
+
ordered.
|
53
|
+
and_return(true)
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
subject.should_receive(:git_force_push).
|
56
|
+
ordered.
|
57
|
+
and_return(true)
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
subject.should_receive(:heroku_migrate).
|
60
|
+
ordered.
|
61
|
+
with(remote_name)
|
64
62
|
|
65
|
-
|
66
|
-
end
|
63
|
+
subject.should_receive(:post_deploy)
|
67
64
|
|
68
|
-
|
69
|
-
|
70
|
-
:pre_deploy => true,
|
71
|
-
:run => true)
|
65
|
+
subject.deploy_to(remote_name)
|
66
|
+
end
|
72
67
|
|
73
|
-
|
68
|
+
it "deploys to the correct remote" do
|
69
|
+
subject.stub(:ensure_heroku_remote_exists_for => true,
|
70
|
+
:pre_deploy => true,
|
71
|
+
:on_cedar? => false,
|
72
|
+
:run => true)
|
74
73
|
|
75
|
-
|
76
|
-
|
74
|
+
subject.should_receive(:git_force_push).with(remote_name)
|
75
|
+
|
76
|
+
subject.deploy_to(remote_name)
|
77
77
|
end
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
describe Kumade::Deployer, "#git_push" do
|
81
|
+
let(:remote){ 'origin' }
|
81
82
|
|
82
|
-
|
83
|
+
before { subject.stub(:say) }
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
it "calls `git push`" do
|
86
|
+
subject.should_receive(:run).
|
87
|
+
with("git push #{remote} master").
|
88
|
+
and_return(true)
|
89
|
+
subject.git_push(remote)
|
90
|
+
end
|
90
91
|
|
91
|
-
|
92
|
-
|
92
|
+
context "when `git push` fails" do
|
93
|
+
before { subject.stub(:run => false) }
|
93
94
|
|
94
|
-
|
95
|
-
|
95
|
+
it "prints an error message" do
|
96
|
+
subject.should_receive(:error).with("Failed to push master -> #{remote}")
|
96
97
|
|
97
|
-
|
98
|
-
end
|
98
|
+
subject.git_push(remote)
|
99
99
|
end
|
100
|
+
end
|
100
101
|
|
101
|
-
|
102
|
-
|
102
|
+
context "when `git push` succeeds" do
|
103
|
+
before { subject.stub(:run => true) }
|
103
104
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
it "does not raise an error" do
|
106
|
+
subject.should_not_receive(:error)
|
107
|
+
subject.git_push(remote)
|
108
|
+
end
|
108
109
|
|
109
|
-
|
110
|
-
|
110
|
+
it "prints a success message" do
|
111
|
+
subject.should_receive(:success).with("Pushed master -> #{remote}")
|
111
112
|
|
112
|
-
|
113
|
-
end
|
113
|
+
subject.git_push(remote)
|
114
114
|
end
|
115
115
|
end
|
116
|
+
end
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
118
|
+
describe Kumade::Deployer, "#git_force_push" do
|
119
|
+
let(:remote){ 'origin' }
|
120
|
+
before { subject.stub(:say) }
|
120
121
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
122
|
+
it "calls `git push -f`" do
|
123
|
+
subject.should_receive(:run).
|
124
|
+
with("git push -f #{remote} master").
|
125
|
+
and_return(true)
|
126
|
+
subject.git_force_push(remote)
|
127
|
+
end
|
127
128
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
context "when `git push -f` fails" do
|
130
|
+
before do
|
131
|
+
subject.stub(:run => false)
|
132
|
+
end
|
132
133
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
end
|
134
|
+
it "prints an error" do
|
135
|
+
subject.should_receive(:error).with("Failed to force push master -> #{remote}")
|
136
|
+
subject.git_force_push(remote)
|
137
137
|
end
|
138
|
+
end
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
context "when `git push -f` succeeds" do
|
141
|
+
before do
|
142
|
+
subject.stub(:run => true)
|
143
|
+
subject.stub(:say)
|
144
|
+
end
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
146
|
+
it "does not raise an error" do
|
147
|
+
subject.should_not_receive(:error)
|
148
|
+
subject.git_force_push(remote)
|
149
|
+
end
|
149
150
|
|
150
|
-
|
151
|
-
|
152
|
-
|
151
|
+
it "prints a success message" do
|
152
|
+
subject.should_receive(:success).
|
153
|
+
with("Force pushed master -> #{remote}")
|
153
154
|
|
154
|
-
|
155
|
-
end
|
155
|
+
subject.git_force_push(remote)
|
156
156
|
end
|
157
157
|
end
|
158
|
+
end
|
158
159
|
|
159
|
-
|
160
|
-
|
160
|
+
describe Kumade::Deployer, "#ensure_clean_git" do
|
161
|
+
before { subject.stub(:say) }
|
161
162
|
|
162
|
-
|
163
|
-
|
163
|
+
context "when git is dirty" do
|
164
|
+
before { subject.stub(:git_dirty? => true) }
|
164
165
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
end
|
166
|
+
it "prints an error" do
|
167
|
+
subject.should_receive(:error).with("Cannot deploy: repo is not clean.")
|
168
|
+
subject.ensure_clean_git
|
169
169
|
end
|
170
|
+
end
|
170
171
|
|
171
|
-
|
172
|
-
|
172
|
+
context "when git is clean" do
|
173
|
+
before { subject.stub(:git_dirty? => false) }
|
173
174
|
|
174
|
-
|
175
|
-
|
176
|
-
|
175
|
+
it "prints a success message" do
|
176
|
+
subject.should_not_receive(:error)
|
177
|
+
subject.should_receive(:success).with("Git repo is clean")
|
177
178
|
|
178
|
-
|
179
|
-
end
|
179
|
+
subject.ensure_clean_git
|
180
180
|
end
|
181
181
|
end
|
182
|
+
end
|
182
183
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
184
|
+
describe Kumade::Deployer, "#ensure_rake_passes" do
|
185
|
+
context "with a default task" do
|
186
|
+
before do
|
187
|
+
subject.stub(:default_task_exists? => true)
|
188
|
+
end
|
188
189
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
190
|
+
it "prints a success message if the default task succeeds" do
|
191
|
+
subject.stub(:rake_succeeded? => true)
|
192
|
+
subject.should_not_receive(:error)
|
193
|
+
subject.should_receive(:success).with("Rake passed")
|
193
194
|
|
194
|
-
|
195
|
-
|
195
|
+
subject.ensure_rake_passes
|
196
|
+
end
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
|
198
|
+
it "prints an error if the default task failse" do
|
199
|
+
subject.stub(:rake_succeeded? => false)
|
200
|
+
subject.should_receive(:error).with("Cannot deploy: tests did not pass")
|
200
201
|
|
201
|
-
|
202
|
-
end
|
202
|
+
subject.ensure_rake_passes
|
203
203
|
end
|
204
204
|
end
|
205
|
+
end
|
205
206
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
end
|
207
|
+
describe Kumade::Deployer, "#default_task_exists?" do
|
208
|
+
it "returns true because a default task does exist" do
|
209
|
+
subject.default_task_exists?.should be_true
|
210
210
|
end
|
211
|
+
end
|
211
212
|
|
212
|
-
|
213
|
-
|
214
|
-
|
213
|
+
describe Kumade::Deployer, "#rake_succeeded?" do
|
214
|
+
it "returns true if the default task passed" do
|
215
|
+
subject.should_receive(:run).with("bundle exec rake").and_return(true)
|
215
216
|
|
216
|
-
|
217
|
-
|
217
|
+
subject.rake_succeeded?.should be_true
|
218
|
+
end
|
218
219
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
end
|
220
|
+
it "returns false if the default task failed" do
|
221
|
+
subject.should_receive(:run).with("bundle exec rake").and_raise("blerg")
|
222
|
+
subject.rake_succeeded?.should be_false
|
223
223
|
end
|
224
|
+
end
|
224
225
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
end
|
226
|
+
describe Kumade::Deployer, "#package_assets" do
|
227
|
+
context "with Jammit installed" do
|
228
|
+
it "calls package_with_jammit" do
|
229
|
+
subject.should_receive(:package_with_jammit)
|
230
|
+
subject.package_assets
|
231
231
|
end
|
232
|
+
end
|
232
233
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
end
|
234
|
+
context "with Jammit not installed" do
|
235
|
+
before { subject.stub(:jammit_installed? => false) }
|
236
|
+
it "does not call package_with_jammit" do
|
237
|
+
subject.should_not_receive(:package_with_jammit)
|
238
|
+
subject.package_assets
|
239
239
|
end
|
240
|
+
end
|
240
241
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
end
|
246
|
-
|
247
|
-
it "calls package_with_more" do
|
248
|
-
subject.should_receive(:package_with_more)
|
249
|
-
subject.package_assets
|
250
|
-
end
|
242
|
+
context "with More installed" do
|
243
|
+
before do
|
244
|
+
subject.stub(:jammit_installed? => false)
|
245
|
+
subject.stub(:more_installed? => true)
|
251
246
|
end
|
252
247
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
subject.stub(:more_installed? => false)
|
257
|
-
end
|
258
|
-
|
259
|
-
it "does not call package_with_more" do
|
260
|
-
subject.should_not_receive(:package_with_more)
|
261
|
-
subject.package_assets
|
262
|
-
end
|
248
|
+
it "calls package_with_more" do
|
249
|
+
subject.should_receive(:package_with_more)
|
250
|
+
subject.package_assets
|
263
251
|
end
|
264
252
|
end
|
265
253
|
|
266
|
-
|
254
|
+
context "with More not installed" do
|
267
255
|
before do
|
268
|
-
subject.stub(:
|
269
|
-
subject.stub(:
|
270
|
-
Jammit.stub(:package!)
|
256
|
+
subject.stub(:jammit_installed? => false)
|
257
|
+
subject.stub(:more_installed? => false)
|
271
258
|
end
|
272
259
|
|
273
|
-
it "
|
274
|
-
|
275
|
-
subject.
|
260
|
+
it "does not call package_with_more" do
|
261
|
+
subject.should_not_receive(:package_with_more)
|
262
|
+
subject.package_assets
|
276
263
|
end
|
264
|
+
end
|
265
|
+
end
|
277
266
|
|
278
|
-
|
279
|
-
|
267
|
+
describe Kumade::Deployer, "#package_with_jammit" do
|
268
|
+
before do
|
269
|
+
subject.stub(:git_add_and_commit_all_assets_in)
|
270
|
+
subject.stub(:say)
|
271
|
+
Jammit.stub(:package!)
|
272
|
+
end
|
280
273
|
|
281
|
-
|
282
|
-
|
274
|
+
it "calls Jammit.package!" do
|
275
|
+
Jammit.should_receive(:package!).once
|
276
|
+
subject.package_with_jammit
|
277
|
+
end
|
283
278
|
|
284
|
-
|
285
|
-
|
279
|
+
context "with updated assets" do
|
280
|
+
before { subject.stub(:git_dirty? => true) }
|
286
281
|
|
287
|
-
|
288
|
-
|
289
|
-
subject.should_receive(:git_add_and_commit_all_assets_in).
|
290
|
-
with('jammit-assets').
|
291
|
-
and_return(true)
|
282
|
+
it "prints the correct message" do
|
283
|
+
subject.should_receive(:success).with("Packaged assets with Jammit")
|
292
284
|
|
293
|
-
|
294
|
-
end
|
285
|
+
subject.package_with_jammit
|
295
286
|
end
|
296
287
|
|
297
|
-
it "
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
288
|
+
it "calls git_add_and_commit_all_assets_in" do
|
289
|
+
subject.stub(:jammit_assets_path => 'jammit-assets')
|
290
|
+
subject.should_receive(:git_add_and_commit_all_assets_in).
|
291
|
+
with('jammit-assets').
|
292
|
+
and_return(true)
|
302
293
|
|
303
294
|
subject.package_with_jammit
|
304
295
|
end
|
296
|
+
end
|
305
297
|
|
306
|
-
|
307
|
-
|
298
|
+
it "prints an error if packaging failed" do
|
299
|
+
Jammit.stub(:package!) do
|
300
|
+
raise Jammit::MissingConfiguration.new("random Jammit error")
|
301
|
+
end
|
302
|
+
subject.should_receive(:error).with("Error: Jammit::MissingConfiguration: random Jammit error")
|
308
303
|
|
309
|
-
|
310
|
-
|
304
|
+
subject.package_with_jammit
|
305
|
+
end
|
311
306
|
|
312
|
-
|
313
|
-
|
307
|
+
context "no assets were added" do
|
308
|
+
before { subject.stub(:git_dirty? => false) }
|
314
309
|
|
315
|
-
|
316
|
-
|
317
|
-
subject.package_with_jammit
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
310
|
+
it "does not call git_add_and_commit_all_jammit_assets" do
|
311
|
+
subject.should_not_receive(:git_add_and_commit_all_assets_in)
|
321
312
|
|
322
|
-
|
323
|
-
before do
|
324
|
-
subject.stub(:git_add_and_commit_all_assets_in => true,
|
325
|
-
:more_assets_path => 'assets')
|
326
|
-
subject.stub(:say)
|
313
|
+
subject.package_with_jammit
|
327
314
|
end
|
328
315
|
|
329
|
-
it "
|
330
|
-
subject.
|
331
|
-
subject.
|
316
|
+
it "does not print a success message" do
|
317
|
+
subject.should_not_receive(:success)
|
318
|
+
subject.package_with_jammit
|
332
319
|
end
|
320
|
+
end
|
321
|
+
end
|
333
322
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
323
|
+
describe Kumade::Deployer, "#package_with_more" do
|
324
|
+
before do
|
325
|
+
subject.stub(:git_add_and_commit_all_assets_in => true,
|
326
|
+
:more_assets_path => 'assets')
|
327
|
+
subject.stub(:say)
|
328
|
+
end
|
339
329
|
|
340
|
-
|
341
|
-
|
330
|
+
it "calls the more:generate task" do
|
331
|
+
subject.should_receive(:run).with("bundle exec rake more:generate")
|
332
|
+
subject.package_with_more
|
333
|
+
end
|
342
334
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
with('blerg').
|
349
|
-
and_return(true)
|
335
|
+
context "with changed assets" do
|
336
|
+
it "prints a success message" do
|
337
|
+
subject.stub(:run).with("bundle exec rake more:generate")
|
338
|
+
subject.stub(:git_dirty? => true)
|
339
|
+
subject.should_receive(:success).with("Packaged assets with More")
|
350
340
|
|
351
|
-
|
352
|
-
end
|
341
|
+
subject.package_with_more
|
353
342
|
end
|
354
343
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
344
|
+
it "calls git_add_and_commit_all_assets_in if assets were added" do
|
345
|
+
subject.stub(:git_dirty? => true,
|
346
|
+
:more_assets_path => 'blerg')
|
347
|
+
subject.stub(:run).with("bundle exec rake more:generate")
|
348
|
+
subject.should_receive(:git_add_and_commit_all_assets_in).
|
349
|
+
with('blerg').
|
350
|
+
and_return(true)
|
360
351
|
|
361
|
-
|
362
|
-
|
352
|
+
subject.package_with_more
|
353
|
+
end
|
354
|
+
end
|
363
355
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
356
|
+
context "with no changed assets" do
|
357
|
+
it "prints no message" do
|
358
|
+
subject.stub(:run).with("bundle exec rake more:generate")
|
359
|
+
subject.stub(:git_dirty? => false)
|
360
|
+
subject.should_not_receive(:say)
|
368
361
|
|
369
|
-
|
370
|
-
end
|
362
|
+
subject.package_with_more
|
371
363
|
end
|
372
364
|
|
373
|
-
it "
|
374
|
-
subject.stub(:
|
375
|
-
|
376
|
-
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
subject.should_receive(:error).with("Error: RuntimeError: blerg")
|
365
|
+
it "does not call git_add_and_commit_all_more_assets" do
|
366
|
+
subject.stub(:run).with("bundle exec rake more:generate")
|
367
|
+
subject.stub(:git_dirty? => false)
|
368
|
+
subject.should_not_receive(:git_add_and_commit_all_assets_in)
|
381
369
|
|
382
370
|
subject.package_with_more
|
383
371
|
end
|
384
372
|
end
|
385
373
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
374
|
+
it "prints an error if packaging failed" do
|
375
|
+
subject.stub(:run) do |arg|
|
376
|
+
if arg == "bundle exec rake more:generate"
|
377
|
+
raise "blerg"
|
378
|
+
end
|
390
379
|
end
|
391
380
|
|
392
|
-
|
393
|
-
subject.should_receive(:success).with("Added and committed all assets")
|
381
|
+
subject.should_receive(:error).with("Error: RuntimeError: blerg")
|
394
382
|
|
395
|
-
|
396
|
-
|
383
|
+
subject.package_with_more
|
384
|
+
end
|
385
|
+
end
|
397
386
|
|
398
|
-
|
399
|
-
|
400
|
-
|
387
|
+
describe Kumade::Deployer, "#git_add_and_commit_all_assets_in" do
|
388
|
+
before do
|
389
|
+
subject.stub(:run => true)
|
390
|
+
subject.stub(:say)
|
391
|
+
end
|
401
392
|
|
402
|
-
|
403
|
-
|
393
|
+
it "prints a success message" do
|
394
|
+
subject.should_receive(:success).with("Added and committed all assets")
|
404
395
|
|
405
|
-
|
406
|
-
|
407
|
-
subject.should_receive(:error).with("Cannot deploy: couldn't commit assets")
|
396
|
+
subject.git_add_and_commit_all_assets_in('blerg')
|
397
|
+
end
|
408
398
|
|
409
|
-
|
410
|
-
|
399
|
+
it "runs the correct commands" do
|
400
|
+
subject.should_receive(:run).
|
401
|
+
with("git checkout -b deploy && git add -f blerg && git commit -m 'Compiled assets'")
|
402
|
+
|
403
|
+
subject.git_add_and_commit_all_assets_in('blerg')
|
411
404
|
end
|
412
405
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
406
|
+
it "prints an error if it could not add and commit assets" do
|
407
|
+
subject.stub(:run => false)
|
408
|
+
subject.should_receive(:error).with("Cannot deploy: couldn't commit assets")
|
409
|
+
|
410
|
+
subject.git_add_and_commit_all_assets_in('blerg')
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
describe Kumade::Deployer, "#jammit_assets_path" do
|
415
|
+
it "returns the correct asset path" do
|
416
|
+
Jammit.stub(:package_path => 'blerg')
|
417
|
+
current_dir = File.expand_path(Dir.pwd)
|
418
|
+
subject.jammit_assets_path.should == File.join(current_dir, 'public', 'blerg')
|
419
419
|
end
|
420
|
+
end
|
420
421
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
end
|
422
|
+
describe Kumade::Deployer, "#more_assets_path" do
|
423
|
+
it "returns the correct asset path" do
|
424
|
+
module ::Less
|
425
|
+
class More
|
426
|
+
def self.destination_path
|
427
|
+
'blerg'
|
428
428
|
end
|
429
429
|
end
|
430
|
-
subject.more_assets_path.should == 'public/blerg'
|
431
430
|
end
|
431
|
+
subject.more_assets_path.should == 'public/blerg'
|
432
432
|
end
|
433
|
+
end
|
433
434
|
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
end
|
435
|
+
describe Kumade::Deployer, "#jammit_installed?" do
|
436
|
+
it "returns true because it's loaded by the Gemfile" do
|
437
|
+
Kumade::Deployer.new.jammit_installed?.should be_true
|
438
438
|
end
|
439
439
|
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
it "returns false if it does not find Less::More" do
|
448
|
-
subject.more_installed?.should be_false
|
449
|
-
end
|
440
|
+
it "returns false if jammit is not installed" do
|
441
|
+
Kumade::Deployer.new.jammit_installed?.should be_true
|
442
|
+
end
|
443
|
+
end
|
450
444
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
end
|
456
|
-
subject.more_installed?.should be_true
|
445
|
+
describe Kumade::Deployer, "#more_installed?" do
|
446
|
+
before do
|
447
|
+
if defined?(Less)
|
448
|
+
Object.send(:remove_const, :Less)
|
457
449
|
end
|
458
450
|
end
|
459
451
|
|
460
|
-
|
461
|
-
|
462
|
-
|
452
|
+
it "returns false if it does not find Less::More" do
|
453
|
+
Kumade::Deployer.new.more_installed?.should be_false
|
454
|
+
end
|
463
455
|
|
464
|
-
|
465
|
-
|
466
|
-
|
456
|
+
it "returns true if it finds Less::More" do
|
457
|
+
module Less
|
458
|
+
class More
|
459
|
+
end
|
467
460
|
end
|
461
|
+
Kumade::Deployer.new.more_installed?.should be_true
|
462
|
+
end
|
463
|
+
end
|
468
464
|
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
subject.should_receive(:run).
|
473
|
-
with("bundle exec heroku rake db:migrate --app #{app_name}")
|
474
|
-
subject.should_receive(:success).with("Migrated #{app_name}")
|
465
|
+
describe Kumade::Deployer, "#heroku_migrate" do
|
466
|
+
let(:environment){ 'staging' }
|
467
|
+
let(:app_name){ 'sushi' }
|
475
468
|
|
476
|
-
|
477
|
-
|
469
|
+
before do
|
470
|
+
subject.stub(:say)
|
471
|
+
force_add_heroku_remote(environment, app_name)
|
478
472
|
end
|
479
473
|
|
480
|
-
|
481
|
-
it "returns false for nil" do
|
482
|
-
subject.string_present?(nil).should be_false
|
483
|
-
end
|
474
|
+
after { remove_remote(environment) }
|
484
475
|
|
485
|
-
|
486
|
-
|
487
|
-
|
476
|
+
it "runs db:migrate with the correct app" do
|
477
|
+
subject.stub(:run => true)
|
478
|
+
subject.should_receive(:heroku).
|
479
|
+
with("rake db:migrate", app_name)
|
480
|
+
subject.should_receive(:success).with("Migrated #{app_name}")
|
488
481
|
|
489
|
-
|
490
|
-
|
491
|
-
|
482
|
+
subject.heroku_migrate(environment)
|
483
|
+
end
|
484
|
+
end
|
492
485
|
|
493
|
-
|
494
|
-
|
495
|
-
|
486
|
+
describe Kumade::Deployer, "#ensure_heroku_remote_exists_for" do
|
487
|
+
let(:environment){ 'staging' }
|
488
|
+
let(:bad_environment){ 'bad' }
|
489
|
+
let(:staging_app_name) { 'staging-sushi' }
|
496
490
|
|
497
|
-
|
498
|
-
|
499
|
-
|
491
|
+
before do
|
492
|
+
subject.stub(:say)
|
493
|
+
force_add_heroku_remote(environment, staging_app_name)
|
494
|
+
`git remote add #{bad_environment} blerg@example.com`
|
500
495
|
end
|
501
496
|
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
497
|
+
after do
|
498
|
+
remove_remote(environment)
|
499
|
+
remove_remote(bad_environment)
|
500
|
+
end
|
506
501
|
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
`git remote add #{bad_environment} blerg@example.com`
|
511
|
-
end
|
502
|
+
context "when the remote points to Heroku" do
|
503
|
+
it "does not print an error" do
|
504
|
+
subject.should_not_receive(:error)
|
512
505
|
|
513
|
-
|
514
|
-
remove_remote(environment)
|
515
|
-
remove_remote(bad_environment)
|
506
|
+
subject.ensure_heroku_remote_exists_for(environment)
|
516
507
|
end
|
517
508
|
|
518
|
-
|
519
|
-
|
520
|
-
subject.should_not_receive(:error)
|
521
|
-
|
522
|
-
subject.ensure_heroku_remote_exists_for(environment)
|
523
|
-
end
|
524
|
-
|
525
|
-
it "prints a success message" do
|
526
|
-
subject.should_receive(:success).with("#{environment} is a Heroku remote")
|
509
|
+
it "prints a success message" do
|
510
|
+
subject.should_receive(:success).with("#{environment} is a Heroku remote")
|
527
511
|
|
528
|
-
|
529
|
-
end
|
512
|
+
subject.ensure_heroku_remote_exists_for(environment)
|
530
513
|
end
|
514
|
+
end
|
531
515
|
|
532
516
|
|
533
|
-
|
534
|
-
|
517
|
+
context "when the remote does not exist" do
|
518
|
+
before { remove_remote(environment) }
|
535
519
|
|
536
|
-
|
537
|
-
|
520
|
+
it "prints an error" do
|
521
|
+
subject.should_receive(:error).with(%{Cannot deploy: "#{environment}" remote does not exist})
|
538
522
|
|
539
|
-
|
540
|
-
end
|
523
|
+
subject.ensure_heroku_remote_exists_for(environment)
|
541
524
|
end
|
525
|
+
end
|
542
526
|
|
543
|
-
|
544
|
-
|
545
|
-
|
527
|
+
context "when the remote does not point to Heroku" do
|
528
|
+
it "prints an error" do
|
529
|
+
subject.should_receive(:error).with(%{Cannot deploy: "#{bad_environment}" remote does not point to Heroku})
|
546
530
|
|
547
|
-
|
548
|
-
end
|
531
|
+
subject.ensure_heroku_remote_exists_for(bad_environment)
|
549
532
|
end
|
550
533
|
end
|
534
|
+
end
|
551
535
|
|
552
|
-
|
553
|
-
|
536
|
+
describe Kumade::Deployer, "#remote_exists?" do
|
537
|
+
let(:remote_name){ 'staging' }
|
554
538
|
|
555
|
-
|
556
|
-
|
539
|
+
before { force_add_heroku_remote(remote_name, 'i-am-a-heroku-app') }
|
540
|
+
after { remove_remote(remote_name) }
|
557
541
|
|
558
|
-
|
559
|
-
|
560
|
-
|
542
|
+
it "returns true if the remote exists" do
|
543
|
+
subject.remote_exists?(remote_name).should be_true
|
544
|
+
end
|
561
545
|
|
562
|
-
|
563
|
-
|
546
|
+
it "returns false if the remote does not exist" do
|
547
|
+
remove_remote(remote_name)
|
564
548
|
|
565
|
-
|
566
|
-
end
|
549
|
+
subject.remote_exists?(remote_name).should be_false
|
567
550
|
end
|
551
|
+
end
|
552
|
+
|
553
|
+
describe Kumade::Deployer, "#heroku" do
|
554
|
+
let(:app_name){ 'sushi' }
|
568
555
|
|
569
|
-
|
570
|
-
|
571
|
-
|
556
|
+
context "when on Cedar" do
|
557
|
+
before { subject.stub(:on_cedar? => true) }
|
558
|
+
it "runs commands with `run`" do
|
559
|
+
subject.should_receive(:run_or_error).with("bundle exec heroku run rake --app #{app_name}", //)
|
560
|
+
subject.heroku("rake", app_name)
|
572
561
|
end
|
573
562
|
end
|
574
563
|
|
575
|
-
|
576
|
-
|
577
|
-
|
564
|
+
context "when not on Cedar" do
|
565
|
+
before { subject.stub(:on_cedar? => false) }
|
566
|
+
it "runs commands without `run`" do
|
567
|
+
subject.should_receive(:run_or_error).with("bundle exec heroku rake --app #{app_name}", //)
|
568
|
+
subject.heroku("rake", app_name)
|
578
569
|
end
|
579
570
|
end
|
571
|
+
end
|
580
572
|
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
573
|
+
describe Kumade::Deployer, "#announce" do
|
574
|
+
it "exists" do
|
575
|
+
subject.should respond_to(:announce)
|
576
|
+
end
|
577
|
+
end
|
578
|
+
|
579
|
+
describe Kumade::Deployer, "#success" do
|
580
|
+
it "exists" do
|
581
|
+
subject.should respond_to(:success)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
describe Kumade::Deployer, "#error" do
|
586
|
+
it "exists" do
|
587
|
+
subject.should respond_to(:error)
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
describe Kumade::Deployer, "#post_deploy" do
|
592
|
+
before { subject.stub(:run => true, :say => true) }
|
593
|
+
|
594
|
+
it "cleans up the deploy branch" do
|
595
|
+
subject.should_receive(:run).with('git checkout master && git branch -D deploy')
|
596
|
+
subject.post_deploy
|
585
597
|
end
|
586
598
|
end
|