kumade 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +72 -0
- data/features/deploying.feature +4 -4
- data/features/loading_tasks.feature +15 -2
- data/features/namespaced_deploy.feature +23 -0
- data/features/step_definitions/task_steps.rb +13 -1
- data/lib/kumade.rb +23 -10
- data/lib/kumade/deployer.rb +25 -2
- data/lib/kumade/tasks/deploy.rake +6 -10
- data/lib/kumade/tasks/namespaced_deploy.rake +18 -0
- data/lib/kumade/version.rb +1 -1
- data/spec/deployer_spec.rb +93 -33
- data/spec/kumade_spec.rb +37 -12
- metadata +109 -61
- data/.rspec +0 -1
- data/.rvmrc +0 -1
data/.gitignore
CHANGED
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Kumade
|
2
|
+
Kumade is a set of basic Rake tasks for deploying to Heroku. It aims to
|
3
|
+
provide most of what you want. Unlike other Heroku deploy gems, it is
|
4
|
+
well-tested.
|
5
|
+
|
6
|
+
## What does Kumade do?
|
7
|
+
Before deploying, Kumade ensures the git repo is clean and that all tests pass.
|
8
|
+
After that, it packages assets using
|
9
|
+
[Jammit](http://documentcloud.github.com/jammit/) and/or
|
10
|
+
[More](https://github.com/cloudhead/more), commits them, and pushes to
|
11
|
+
origin. Then it force pushes to the staging or production remote as
|
12
|
+
appropriate and runs `rake db:migrate` on the Heroku app.
|
13
|
+
|
14
|
+
If any step fails, it immediately raises an error and stops the deploy
|
15
|
+
process.
|
16
|
+
|
17
|
+
## Install
|
18
|
+
In your Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'kumade'
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
In your Rakefile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Kumade.load_tasks
|
29
|
+
## Set the name of the staging remote (autodetected by default)
|
30
|
+
# Kumade.staging_remote = 'staging'
|
31
|
+
## Set the name of the production remote (autodetected by default)
|
32
|
+
# Kumade.production_remote = 'production'
|
33
|
+
|
34
|
+
# Set the name of the staging app on Heroku (required)
|
35
|
+
Kumade.staging_app = 'my-staging-app'
|
36
|
+
# Set the name of the production app on Heroku (required)
|
37
|
+
Kumade.production_app = 'my-production-app'
|
38
|
+
```
|
39
|
+
|
40
|
+
Now running `rake -T` shows the new tasks:
|
41
|
+
|
42
|
+
```bash
|
43
|
+
rake deploy # Alias for kumade:deploy
|
44
|
+
rake deploy:production # Alias for kumade:deploy:production
|
45
|
+
rake deploy:staging # Alias for kumade:deploy:staging
|
46
|
+
|
47
|
+
rake kumade:deploy # Alias for kumade:deploy:staging
|
48
|
+
rake kumade:deploy:production # Deploy to Heroku production
|
49
|
+
rake kumade:deploy:staging # Deploy to Heroku staging
|
50
|
+
```
|
51
|
+
|
52
|
+
If you only want the namespaced tasks (the ones with "kumade:" in front), do
|
53
|
+
this in your Rakefile:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
Kumade.load_namespaced_tasks
|
57
|
+
```
|
58
|
+
|
59
|
+
Now `rake -T` will only show this:
|
60
|
+
|
61
|
+
```bash
|
62
|
+
rake kumade:deploy # Alias for kumade:deploy:staging
|
63
|
+
rake kumade:deploy:production # Deploy to Heroku production
|
64
|
+
rake kumade:deploy:staging # Deploy to Heroku staging
|
65
|
+
```
|
66
|
+
|
67
|
+
## Compatibility
|
68
|
+
Tested on MRI 1.8.7 and 1.9.2.
|
69
|
+
|
70
|
+
## What's with the name?
|
71
|
+
Kumade ([pronunciation here](http://translate.google.com/#ja|en|熊手)) means
|
72
|
+
"bamboo rake" in Japanese.
|
data/features/deploying.feature
CHANGED
@@ -8,16 +8,16 @@ Feature: Deploying to Heroku
|
|
8
8
|
And I cd to "deployer"
|
9
9
|
And I stub out the "staging" deploy method
|
10
10
|
And I stub out the "production" deploy method
|
11
|
-
And I load the tasks
|
11
|
+
And I load the non-namespaced tasks
|
12
12
|
|
13
|
-
Scenario: deploy task is an alias for deploy
|
13
|
+
Scenario: deploy task is an alias for kumade:deploy
|
14
14
|
When I successfully run the rake task "deploy"
|
15
15
|
Then the output should contain "Force pushed master -> staging"
|
16
16
|
|
17
|
-
Scenario: Deploying to staging
|
17
|
+
Scenario: Deploying to staging with deploy:staging
|
18
18
|
When I successfully run the rake task "deploy:staging"
|
19
19
|
Then the output should contain "Force pushed master -> staging"
|
20
20
|
|
21
|
-
Scenario: Deploying to production
|
21
|
+
Scenario: Deploying to production with deploy:production
|
22
22
|
When I successfully run the rake task "deploy:production"
|
23
23
|
Then the output should contain "Force pushed master -> production"
|
@@ -3,7 +3,7 @@ Feature: Loading tasks
|
|
3
3
|
As a user
|
4
4
|
I want to load Rake tasks
|
5
5
|
|
6
|
-
|
6
|
+
Background:
|
7
7
|
Given a directory named "taskloader"
|
8
8
|
When I cd to "taskloader"
|
9
9
|
And I write to "Gemfile" with:
|
@@ -12,7 +12,9 @@ Feature: Loading tasks
|
|
12
12
|
gem "rake", "0.8.7"
|
13
13
|
gem "kumade"
|
14
14
|
"""
|
15
|
-
|
15
|
+
|
16
|
+
Scenario: Load non-namespaced Rake tasks
|
17
|
+
When I write to "Rakefile" with:
|
16
18
|
"""
|
17
19
|
require 'kumade'
|
18
20
|
Kumade.load_tasks
|
@@ -21,3 +23,14 @@ Feature: Loading tasks
|
|
21
23
|
Then the output should contain "deploy"
|
22
24
|
And the output should contain "deploy:staging"
|
23
25
|
And the output should contain "deploy:production"
|
26
|
+
|
27
|
+
Scenario: Load namespaced Rake tasks
|
28
|
+
When I write to "Rakefile" with:
|
29
|
+
"""
|
30
|
+
require 'kumade'
|
31
|
+
Kumade.load_namespaced_tasks
|
32
|
+
"""
|
33
|
+
And I run `rake -T`
|
34
|
+
Then the output should contain "kumade:deploy"
|
35
|
+
And the output should contain "kumade:deploy:staging"
|
36
|
+
And the output should contain "kumade:deploy:production"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: Namespaced deploy tasks
|
2
|
+
In order to avoid task name conflicts
|
3
|
+
As a user
|
4
|
+
I want to have namespaced deploy tasks
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a directory named "deployer"
|
8
|
+
And I cd to "deployer"
|
9
|
+
And I stub out the "staging" deploy method
|
10
|
+
And I stub out the "production" deploy method
|
11
|
+
And I load the namespaced tasks
|
12
|
+
|
13
|
+
Scenario: kumade:deploy task is an alias for kumade:deploy:staging
|
14
|
+
When I successfully run the rake task "kumade:deploy"
|
15
|
+
Then the output should contain "Force pushed master -> staging"
|
16
|
+
|
17
|
+
Scenario: Deploying to staging
|
18
|
+
When I successfully run the rake task "kumade:deploy:staging"
|
19
|
+
Then the output should contain "Force pushed master -> staging"
|
20
|
+
|
21
|
+
Scenario: Deploying to production
|
22
|
+
When I successfully run the rake task "kumade:deploy:production"
|
23
|
+
Then the output should contain "Force pushed master -> production"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Given /^I load the non\-namespaced tasks$/ do
|
2
2
|
prepend_require_kumade_to_rakefile!
|
3
3
|
|
4
4
|
steps %{
|
@@ -10,6 +10,18 @@ When /^I load the tasks$/ do
|
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
13
|
+
Given /^I load the namespaced tasks$/ do
|
14
|
+
prepend_require_kumade_to_rakefile!
|
15
|
+
|
16
|
+
steps %{
|
17
|
+
When I append to "Rakefile" with:
|
18
|
+
"""
|
19
|
+
|
20
|
+
Kumade.load_namespaced_tasks
|
21
|
+
"""
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
13
25
|
When /^I successfully run the rake task "([^"]*)"$/ do |task_name|
|
14
26
|
When %{I successfully run `bundle exec rake #{task_name}`}
|
15
27
|
end
|
data/lib/kumade.rb
CHANGED
@@ -5,28 +5,41 @@ class Kumade
|
|
5
5
|
deployer.load_tasks
|
6
6
|
end
|
7
7
|
|
8
|
+
def self.load_namespaced_tasks
|
9
|
+
deployer.load_namespaced_tasks
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.deployer
|
13
|
+
@deployer ||= Deployer.new
|
14
|
+
end
|
15
|
+
|
8
16
|
class << self
|
9
|
-
attr_writer :
|
17
|
+
attr_writer :staging_remote, :production_remote
|
10
18
|
attr_accessor :staging_app, :production_app
|
11
19
|
|
12
20
|
def reset!
|
13
|
-
@
|
14
|
-
@
|
21
|
+
@staging_remote = nil
|
22
|
+
@production_remote = nil
|
15
23
|
|
16
24
|
@staging_app = nil
|
17
25
|
@production_app = nil
|
18
26
|
end
|
19
27
|
|
20
|
-
def
|
21
|
-
@
|
28
|
+
def staging_remote
|
29
|
+
@staging_remote ||= local_remote_for_app(Kumade.staging_app)
|
22
30
|
end
|
23
31
|
|
24
|
-
def
|
25
|
-
@
|
32
|
+
def production_remote
|
33
|
+
@production_remote ||= local_remote_for_app(Kumade.production_app)
|
26
34
|
end
|
27
|
-
end
|
28
35
|
|
29
|
-
|
30
|
-
|
36
|
+
def local_remote_for_app(app_name)
|
37
|
+
heroku_remote_url = heroku_remote_url_for_app(app_name)
|
38
|
+
`git remote -v | grep push | grep '#{heroku_remote_url}' | cut -f1`.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
def heroku_remote_url_for_app(app_name)
|
42
|
+
"git@heroku.com:#{app_name}.git"
|
43
|
+
end
|
31
44
|
end
|
32
45
|
end
|
data/lib/kumade/deployer.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
class Kumade
|
2
2
|
class Deployer
|
3
3
|
def load_tasks
|
4
|
+
load_namespaced_tasks
|
4
5
|
load 'kumade/tasks/deploy.rake'
|
5
6
|
end
|
6
7
|
|
8
|
+
def load_namespaced_tasks
|
9
|
+
load 'kumade/tasks/namespaced_deploy.rake'
|
10
|
+
end
|
11
|
+
|
7
12
|
def pre_deploy
|
8
13
|
ensure_clean_git
|
9
14
|
ensure_rake_passes
|
@@ -12,14 +17,16 @@ class Kumade
|
|
12
17
|
end
|
13
18
|
|
14
19
|
def deploy_to_staging
|
20
|
+
ensure_staging_app_is_present
|
15
21
|
pre_deploy
|
16
|
-
git_force_push(Kumade.
|
22
|
+
git_force_push(Kumade.staging_remote)
|
17
23
|
heroku_migrate(:staging)
|
18
24
|
end
|
19
25
|
|
20
26
|
def deploy_to_production
|
27
|
+
ensure_production_app_is_present
|
21
28
|
pre_deploy
|
22
|
-
git_force_push(Kumade.
|
29
|
+
git_force_push(Kumade.production_remote)
|
23
30
|
heroku_migrate(:production)
|
24
31
|
end
|
25
32
|
|
@@ -149,5 +156,21 @@ class Kumade
|
|
149
156
|
def announce(message)
|
150
157
|
puts message
|
151
158
|
end
|
159
|
+
|
160
|
+
def string_present?(maybe_string)
|
161
|
+
maybe_string.is_a?(String) && maybe_string.size > 0
|
162
|
+
end
|
163
|
+
|
164
|
+
def ensure_staging_app_is_present
|
165
|
+
unless string_present?(Kumade.staging_app)
|
166
|
+
raise "Cannot deploy: Kumade.staging_app is not present"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def ensure_production_app_is_present
|
171
|
+
unless string_present?(Kumade.production_app)
|
172
|
+
raise "Cannot deploy: Kumade.production_app is not present"
|
173
|
+
end
|
174
|
+
end
|
152
175
|
end
|
153
176
|
end
|
@@ -1,16 +1,12 @@
|
|
1
1
|
class Kumade
|
2
|
-
desc "Alias for deploy
|
3
|
-
task :deploy =>
|
2
|
+
desc "Alias for kumade:deploy"
|
3
|
+
task :deploy => "kumade:deploy"
|
4
4
|
|
5
5
|
namespace :deploy do
|
6
|
-
desc "
|
7
|
-
task :staging
|
8
|
-
deployer.deploy_to_staging
|
9
|
-
end
|
6
|
+
desc "Alias for kumade:deploy:staging"
|
7
|
+
task :staging => "kumade:deploy:staging"
|
10
8
|
|
11
|
-
desc "
|
12
|
-
task :production
|
13
|
-
deployer.deploy_to_production
|
14
|
-
end
|
9
|
+
desc "Alias for kumade:deploy:production"
|
10
|
+
task :production => "kumade:deploy:production"
|
15
11
|
end
|
16
12
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Kumade
|
2
|
+
namespace :kumade do
|
3
|
+
desc "Alias for kumade:deploy:staging"
|
4
|
+
task :deploy => "deploy:staging"
|
5
|
+
|
6
|
+
namespace :deploy do
|
7
|
+
desc "Deploy to Heroku staging"
|
8
|
+
task :staging do
|
9
|
+
deployer.deploy_to_staging
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Deploy to Heroku production"
|
13
|
+
task :production do
|
14
|
+
deployer.deploy_to_production
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/kumade/version.rb
CHANGED
data/spec/deployer_spec.rb
CHANGED
@@ -32,13 +32,15 @@ class Kumade
|
|
32
32
|
it "calls the correct methods in order" do
|
33
33
|
subject.stub(:run => true)
|
34
34
|
|
35
|
+
subject.should_receive(:ensure_staging_app_is_present).
|
36
|
+
ordered
|
37
|
+
|
35
38
|
subject.should_receive(:pre_deploy).
|
36
39
|
ordered.
|
37
40
|
and_return(true)
|
38
41
|
|
39
42
|
subject.should_receive(:git_force_push).
|
40
43
|
ordered.
|
41
|
-
with('staging').
|
42
44
|
and_return(true)
|
43
45
|
|
44
46
|
subject.should_receive(:heroku_migrate).
|
@@ -51,7 +53,8 @@ class Kumade
|
|
51
53
|
it "deploys to Kumade.staging" do
|
52
54
|
subject.stub(:pre_deploy => true,
|
53
55
|
:run => true)
|
54
|
-
|
56
|
+
subject.stub(:ensure_staging_app_is_present)
|
57
|
+
Kumade.staging_remote = 'orange'
|
55
58
|
|
56
59
|
subject.should_receive(:git_force_push).with('orange')
|
57
60
|
|
@@ -63,13 +66,15 @@ class Kumade
|
|
63
66
|
it "calls the correct methods in order" do
|
64
67
|
subject.stub(:run => true)
|
65
68
|
|
69
|
+
subject.should_receive(:ensure_production_app_is_present).
|
70
|
+
ordered
|
71
|
+
|
66
72
|
subject.should_receive(:pre_deploy).
|
67
73
|
ordered.
|
68
74
|
and_return(true)
|
69
75
|
|
70
76
|
subject.should_receive(:git_force_push).
|
71
77
|
ordered.
|
72
|
-
with('production').
|
73
78
|
and_return(true)
|
74
79
|
|
75
80
|
subject.should_receive(:heroku_migrate).
|
@@ -82,9 +87,11 @@ class Kumade
|
|
82
87
|
it "deploys to Kumade.production" do
|
83
88
|
subject.stub(:pre_deploy => true,
|
84
89
|
:run => true)
|
85
|
-
|
90
|
+
subject.stub(:ensure_production_app_is_present)
|
86
91
|
|
87
|
-
|
92
|
+
Kumade.production_remote = 'bamboo'
|
93
|
+
|
94
|
+
subject.should_receive(:git_force_push).with('bamboo')
|
88
95
|
|
89
96
|
subject.deploy_to_production
|
90
97
|
end
|
@@ -104,7 +111,7 @@ class Kumade
|
|
104
111
|
|
105
112
|
context "when `git push` fails" do
|
106
113
|
before do
|
107
|
-
subject.stub(:run
|
114
|
+
subject.stub(:run => false)
|
108
115
|
end
|
109
116
|
|
110
117
|
it "raises an error" do
|
@@ -116,11 +123,11 @@ class Kumade
|
|
116
123
|
|
117
124
|
context "when `git push` succeeds" do
|
118
125
|
before do
|
119
|
-
subject.stub(:run
|
126
|
+
subject.stub(:run => true)
|
120
127
|
end
|
121
128
|
|
122
129
|
it "does not raise an error" do
|
123
|
-
subject.stub(:announce
|
130
|
+
subject.stub(:announce => false)
|
124
131
|
lambda do
|
125
132
|
subject.git_push(remote)
|
126
133
|
end.should_not raise_error
|
@@ -148,7 +155,7 @@ class Kumade
|
|
148
155
|
|
149
156
|
context "when `git push -f` fails" do
|
150
157
|
before do
|
151
|
-
subject.stub(:run
|
158
|
+
subject.stub(:run => false)
|
152
159
|
end
|
153
160
|
|
154
161
|
it "raises an error" do
|
@@ -160,7 +167,7 @@ class Kumade
|
|
160
167
|
|
161
168
|
context "when `git push -f` succeeds" do
|
162
169
|
before do
|
163
|
-
subject.stub(:run
|
170
|
+
subject.stub(:run => true)
|
164
171
|
end
|
165
172
|
|
166
173
|
it "does not raise an error" do
|
@@ -180,7 +187,7 @@ class Kumade
|
|
180
187
|
|
181
188
|
describe Deployer, "#ensure_clean_git" do
|
182
189
|
context "when git is dirty" do
|
183
|
-
before { subject.stub(:git_dirty?
|
190
|
+
before { subject.stub(:git_dirty? => true) }
|
184
191
|
|
185
192
|
it "raises an error" do
|
186
193
|
lambda do
|
@@ -190,7 +197,7 @@ class Kumade
|
|
190
197
|
end
|
191
198
|
|
192
199
|
context "when git is clean" do
|
193
|
-
before { subject.stub(:git_dirty?
|
200
|
+
before { subject.stub(:git_dirty? => false) }
|
194
201
|
|
195
202
|
it "does not raise an error" do
|
196
203
|
lambda do
|
@@ -203,18 +210,18 @@ class Kumade
|
|
203
210
|
describe Deployer, "#ensure_rake_passes" do
|
204
211
|
context "with a default task" do
|
205
212
|
before do
|
206
|
-
subject.stub(:default_task_exists?
|
213
|
+
subject.stub(:default_task_exists? => true)
|
207
214
|
end
|
208
215
|
|
209
216
|
it "does not raise an error if the default task succeeds" do
|
210
|
-
subject.stub(:rake_succeeded?
|
217
|
+
subject.stub(:rake_succeeded? => true)
|
211
218
|
lambda do
|
212
219
|
subject.ensure_rake_passes
|
213
220
|
end.should_not raise_error
|
214
221
|
end
|
215
222
|
|
216
223
|
it "raises an error if the default task failse" do
|
217
|
-
subject.stub(:rake_succeeded?
|
224
|
+
subject.stub(:rake_succeeded? => false)
|
218
225
|
lambda do
|
219
226
|
subject.ensure_rake_passes
|
220
227
|
end.should raise_error("Cannot deploy: tests did not pass")
|
@@ -321,8 +328,8 @@ class Kumade
|
|
321
328
|
end
|
322
329
|
|
323
330
|
it "calls git_add_and_commit_all_assets_in if assets were added" do
|
324
|
-
subject.stub(:git_dirty?
|
325
|
-
|
331
|
+
subject.stub(:git_dirty? => true,
|
332
|
+
:absolute_assets_path => 'blerg')
|
326
333
|
subject.should_receive(:git_add_and_commit_all_assets_in).
|
327
334
|
with('blerg').
|
328
335
|
and_return(true)
|
@@ -331,7 +338,7 @@ class Kumade
|
|
331
338
|
end
|
332
339
|
|
333
340
|
it "does not call git_add_and_commit_all_jammit_assets if no assets were added" do
|
334
|
-
subject.stub(:git_dirty?
|
341
|
+
subject.stub(:git_dirty? => false)
|
335
342
|
subject.should_receive(:git_add_and_commit_all_assets_in).exactly(0).times
|
336
343
|
|
337
344
|
subject.package_with_jammit
|
@@ -340,17 +347,11 @@ class Kumade
|
|
340
347
|
|
341
348
|
describe Deployer, "#package_with_more" do
|
342
349
|
before do
|
343
|
-
subject.stub(:git_add_and_commit_all_assets_in
|
344
|
-
|
350
|
+
subject.stub(:git_add_and_commit_all_assets_in => true,
|
351
|
+
:more_assets_path => 'assets',
|
352
|
+
:announce => nil)
|
345
353
|
Rake::Task.clear
|
346
354
|
Rake::Task.define_task('more:generate'){}
|
347
|
-
module ::Less
|
348
|
-
class More
|
349
|
-
def self.destination_path
|
350
|
-
'blerg'
|
351
|
-
end
|
352
|
-
end
|
353
|
-
end
|
354
355
|
end
|
355
356
|
|
356
357
|
it "calls the more:generate task" do
|
@@ -361,6 +362,7 @@ class Kumade
|
|
361
362
|
end
|
362
363
|
|
363
364
|
it "prints the correct message if packaging succeeded" do
|
365
|
+
subject.stub(:git_dirty? => true)
|
364
366
|
subject.should_receive(:announce).with("Successfully packaged with More")
|
365
367
|
|
366
368
|
subject.package_with_more
|
@@ -385,8 +387,8 @@ class Kumade
|
|
385
387
|
end
|
386
388
|
|
387
389
|
it "calls git_add_and_commit_all_assets_in if assets were added" do
|
388
|
-
subject.stub(:git_dirty?
|
389
|
-
|
390
|
+
subject.stub(:git_dirty? => true,
|
391
|
+
:more_assets_path => 'blerg')
|
390
392
|
subject.should_receive(:git_add_and_commit_all_assets_in).
|
391
393
|
with('blerg').
|
392
394
|
and_return(true)
|
@@ -395,7 +397,7 @@ class Kumade
|
|
395
397
|
end
|
396
398
|
|
397
399
|
it "does not call git_add_and_commit_all_more_assets if no assets were added" do
|
398
|
-
subject.stub(:git_dirty?
|
400
|
+
subject.stub(:git_dirty? => false)
|
399
401
|
subject.should_receive(:git_add_and_commit_all_assets_in).exactly(0).times
|
400
402
|
|
401
403
|
subject.package_with_more
|
@@ -404,8 +406,8 @@ class Kumade
|
|
404
406
|
|
405
407
|
describe Deployer, "#git_add_and_commit_all_assets_in" do
|
406
408
|
before do
|
407
|
-
subject.stub(:
|
408
|
-
|
409
|
+
subject.stub(:run => true,
|
410
|
+
:announce => nil)
|
409
411
|
end
|
410
412
|
|
411
413
|
it "announces the correct message" do
|
@@ -422,7 +424,7 @@ class Kumade
|
|
422
424
|
end
|
423
425
|
|
424
426
|
it "raises an error if it could not add and commit assets" do
|
425
|
-
subject.stub(:run
|
427
|
+
subject.stub(:run => false)
|
426
428
|
|
427
429
|
lambda do
|
428
430
|
subject.git_add_and_commit_all_assets_in('blerg')
|
@@ -501,4 +503,62 @@ class Kumade
|
|
501
503
|
subject.heroku_migrate(:production)
|
502
504
|
end
|
503
505
|
end
|
506
|
+
|
507
|
+
describe Deployer, "#string_present?" do
|
508
|
+
it "returns false for nil" do
|
509
|
+
subject.string_present?(nil).should be_false
|
510
|
+
end
|
511
|
+
|
512
|
+
it "returns false for false" do
|
513
|
+
subject.string_present?(false).should be_false
|
514
|
+
end
|
515
|
+
|
516
|
+
it "returns false for true" do
|
517
|
+
subject.string_present?(true).should be_false
|
518
|
+
end
|
519
|
+
|
520
|
+
it "returns false for an empty string" do
|
521
|
+
subject.string_present?('').should be_false
|
522
|
+
end
|
523
|
+
|
524
|
+
it "returns true for a non-empty string" do
|
525
|
+
subject.string_present?('abc').should be_true
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
describe Deployer, "#ensure_staging_app_is_present" do
|
530
|
+
after { Kumade.reset! }
|
531
|
+
|
532
|
+
it "does not raise an error if Kumade.staging_app is present" do
|
533
|
+
Kumade.staging_app = 'abc'
|
534
|
+
lambda do
|
535
|
+
subject.ensure_staging_app_is_present
|
536
|
+
end.should_not raise_error
|
537
|
+
end
|
538
|
+
|
539
|
+
it "raises an error if Kumade.staging_app is not present" do
|
540
|
+
Kumade.staging_app = ''
|
541
|
+
lambda do
|
542
|
+
subject.ensure_staging_app_is_present
|
543
|
+
end.should raise_error("Cannot deploy: Kumade.staging_app is not present")
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
describe Deployer, "#ensure_production_app_is_present" do
|
548
|
+
after { Kumade.reset! }
|
549
|
+
|
550
|
+
it "does not raise an error if Kumade.production_app is present" do
|
551
|
+
Kumade.production_app = 'abc'
|
552
|
+
lambda do
|
553
|
+
subject.ensure_production_app_is_present
|
554
|
+
end.should_not raise_error
|
555
|
+
end
|
556
|
+
|
557
|
+
it "raises an error if Kumade.production_app is not present" do
|
558
|
+
Kumade.production_app = ''
|
559
|
+
lambda do
|
560
|
+
subject.ensure_production_app_is_present
|
561
|
+
end.should raise_error("Cannot deploy: Kumade.production_app is not present")
|
562
|
+
end
|
563
|
+
end
|
504
564
|
end
|
data/spec/kumade_spec.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kumade, "
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
describe Kumade, ".staging_remote" do
|
4
|
+
let(:staging_app){ 'purple' }
|
5
|
+
let(:staging_remote){ 'staging_test' }
|
6
|
+
|
7
|
+
before do
|
8
|
+
Kumade.reset!
|
9
|
+
`git remote add #{staging_remote} git@heroku.com:#{staging_app}.git`
|
7
10
|
end
|
8
11
|
|
12
|
+
after { `git remote rm #{staging_remote}` }
|
13
|
+
|
9
14
|
it "can be set" do
|
10
|
-
Kumade.
|
11
|
-
Kumade.
|
15
|
+
Kumade.staging_remote = 'orange'
|
16
|
+
Kumade.staging_remote.should == 'orange'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is autodetected if staging app is set" do
|
20
|
+
Kumade.staging_app = staging_app
|
21
|
+
Kumade.staging_remote.should == staging_remote
|
12
22
|
end
|
13
23
|
end
|
14
24
|
|
@@ -25,16 +35,25 @@ describe Kumade, "staging app" do
|
|
25
35
|
end
|
26
36
|
end
|
27
37
|
|
28
|
-
describe Kumade, "
|
29
|
-
|
38
|
+
describe Kumade, ".production_remote" do
|
39
|
+
let(:production_app){ 'purple' }
|
40
|
+
let(:production_remote){ 'production_test' }
|
30
41
|
|
31
|
-
|
32
|
-
Kumade.
|
42
|
+
before do
|
43
|
+
Kumade.reset!
|
44
|
+
`git remote add #{production_remote} git@heroku.com:#{production_app}.git`
|
33
45
|
end
|
34
46
|
|
47
|
+
after { `git remote rm #{production_remote}` }
|
48
|
+
|
35
49
|
it "can be set" do
|
36
|
-
Kumade.
|
37
|
-
Kumade.
|
50
|
+
Kumade.production_remote = 'orange'
|
51
|
+
Kumade.production_remote.should == 'orange'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "is autodetected if production app is set" do
|
55
|
+
Kumade.production_app = production_app
|
56
|
+
Kumade.production_remote.should == production_remote
|
38
57
|
end
|
39
58
|
end
|
40
59
|
|
@@ -50,3 +69,9 @@ describe Kumade, "production app" do
|
|
50
69
|
Kumade.production_app.should == 'orange'
|
51
70
|
end
|
52
71
|
end
|
72
|
+
|
73
|
+
describe Kumade, "heroku_remote_url_for_app" do
|
74
|
+
it "returns the Heroku remote_url for an app" do
|
75
|
+
Kumade.heroku_remote_url_for_app('blerg').should == 'git@heroku.com:blerg.git'
|
76
|
+
end
|
77
|
+
end
|
metadata
CHANGED
@@ -1,97 +1,134 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumade
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Gabe Berke-Williams
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2011-07-26 00:00:00 -04:00
|
13
19
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
16
22
|
name: heroku
|
17
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
25
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
23
33
|
type: :runtime
|
24
|
-
|
25
|
-
|
26
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
27
36
|
name: rake
|
28
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
39
|
none: false
|
30
|
-
requirements:
|
40
|
+
requirements:
|
31
41
|
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 49
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 8
|
47
|
+
- 7
|
33
48
|
version: 0.8.7
|
34
49
|
type: :development
|
35
|
-
|
36
|
-
|
37
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
38
52
|
name: rspec
|
39
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
55
|
none: false
|
41
|
-
requirements:
|
56
|
+
requirements:
|
42
57
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 23
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 6
|
63
|
+
- 0
|
44
64
|
version: 2.6.0
|
45
65
|
type: :development
|
46
|
-
|
47
|
-
|
48
|
-
- !ruby/object:Gem::Dependency
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
49
68
|
name: cucumber
|
50
|
-
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
71
|
none: false
|
52
|
-
requirements:
|
72
|
+
requirements:
|
53
73
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 19
|
76
|
+
segments:
|
77
|
+
- 1
|
78
|
+
- 0
|
79
|
+
- 2
|
55
80
|
version: 1.0.2
|
56
81
|
type: :development
|
57
|
-
|
58
|
-
|
59
|
-
- !ruby/object:Gem::Dependency
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
60
84
|
name: aruba
|
61
|
-
|
85
|
+
prerelease: false
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
62
87
|
none: false
|
63
|
-
requirements:
|
88
|
+
requirements:
|
64
89
|
- - ~>
|
65
|
-
- !ruby/object:Gem::Version
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 9
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
- 4
|
95
|
+
- 3
|
66
96
|
version: 0.4.3
|
67
97
|
type: :development
|
68
|
-
|
69
|
-
|
70
|
-
- !ruby/object:Gem::Dependency
|
98
|
+
version_requirements: *id005
|
99
|
+
- !ruby/object:Gem::Dependency
|
71
100
|
name: jammit
|
72
|
-
|
101
|
+
prerelease: false
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
73
103
|
none: false
|
74
|
-
requirements:
|
104
|
+
requirements:
|
75
105
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 1
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
- 6
|
111
|
+
- 3
|
77
112
|
version: 0.6.3
|
78
113
|
type: :development
|
79
|
-
|
80
|
-
version_requirements: *2152567320
|
114
|
+
version_requirements: *id006
|
81
115
|
description: Simple rake tasks for deploying to Heroku
|
82
|
-
email:
|
116
|
+
email:
|
83
117
|
- gabe@thoughtbot.com
|
84
118
|
executables: []
|
119
|
+
|
85
120
|
extensions: []
|
121
|
+
|
86
122
|
extra_rdoc_files: []
|
87
|
-
|
123
|
+
|
124
|
+
files:
|
88
125
|
- .gitignore
|
89
|
-
- .rspec
|
90
|
-
- .rvmrc
|
91
126
|
- Gemfile
|
127
|
+
- README.md
|
92
128
|
- Rakefile
|
93
129
|
- features/deploying.feature
|
94
130
|
- features/loading_tasks.feature
|
131
|
+
- features/namespaced_deploy.feature
|
95
132
|
- features/step_definitions/stub_steps.rb
|
96
133
|
- features/step_definitions/task_steps.rb
|
97
134
|
- features/support/env.rb
|
@@ -101,38 +138,49 @@ files:
|
|
101
138
|
- lib/kumade.rb
|
102
139
|
- lib/kumade/deployer.rb
|
103
140
|
- lib/kumade/tasks/deploy.rake
|
141
|
+
- lib/kumade/tasks/namespaced_deploy.rake
|
104
142
|
- lib/kumade/version.rb
|
105
143
|
- spec/deployer_spec.rb
|
106
144
|
- spec/kumade_spec.rb
|
107
145
|
- spec/spec_helper.rb
|
108
146
|
has_rdoc: true
|
109
|
-
homepage:
|
147
|
+
homepage: ""
|
110
148
|
licenses: []
|
149
|
+
|
111
150
|
post_install_message:
|
112
151
|
rdoc_options: []
|
113
|
-
|
152
|
+
|
153
|
+
require_paths:
|
114
154
|
- lib
|
115
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
156
|
none: false
|
117
|
-
requirements:
|
118
|
-
- -
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
|
121
|
-
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
hash: 3
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
version: "0"
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
165
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
hash: 3
|
170
|
+
segments:
|
171
|
+
- 0
|
172
|
+
version: "0"
|
127
173
|
requirements: []
|
174
|
+
|
128
175
|
rubyforge_project:
|
129
176
|
rubygems_version: 1.6.2
|
130
177
|
signing_key:
|
131
178
|
specification_version: 3
|
132
179
|
summary: Simple rake tasks for deploying to Heroku
|
133
|
-
test_files:
|
180
|
+
test_files:
|
134
181
|
- features/deploying.feature
|
135
182
|
- features/loading_tasks.feature
|
183
|
+
- features/namespaced_deploy.feature
|
136
184
|
- features/step_definitions/stub_steps.rb
|
137
185
|
- features/step_definitions/task_steps.rb
|
138
186
|
- features/support/env.rb
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm 1.9.2@kumade
|