cape 1.1.0 → 1.2.0
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/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/Gemfile +11 -9
- data/Guardfile +17 -0
- data/History.markdown +10 -0
- data/MIT-LICENSE.markdown +1 -1
- data/README.markdown +58 -9
- data/Rakefile +1 -1
- data/cape.gemspec +13 -12
- data/features/dsl/each_rake_task/with_defined_namespace_argument.feature +8 -0
- data/features/dsl/each_rake_task/with_undefined_argument.feature +25 -1
- data/features/dsl/each_rake_task/without_arguments.feature +8 -0
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_namespace_argument.feature +25 -0
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/without_arguments.feature +50 -4
- data/features/dsl/mirror_rake_tasks/with_defined_namespace_argument.feature +19 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_arguments_and_environment_variables.feature +199 -0
- data/features/dsl/mirror_rake_tasks/with_valid_options_argument.feature +90 -0
- data/features/dsl/mirror_rake_tasks/without_arguments.feature +48 -5
- data/features/dsl/rake_executable.feature +10 -6
- data/features/step_definitions.rb +3 -0
- data/lib/cape/capistrano.rb +70 -40
- data/lib/cape/dsl.rb +76 -13
- data/lib/cape/rake.rb +30 -6
- data/lib/cape/version.rb +1 -1
- data/spec/cape/capistrano_spec.rb +16 -0
- data/spec/cape/dsl_spec.rb +108 -29
- data/spec/cape/rake_spec.rb +40 -0
- data/spec/cape/util_spec.rb +2 -2
- data/spec/cape/version_spec.rb +0 -1
- data/spec/cape_spec.rb +21 -3
- metadata +24 -18
- data/spec/cape/task_spec.rb +0 -0
@@ -36,6 +36,25 @@ Feature: The #mirror_rake_tasks DSL method with an argument of a defined namespa
|
|
36
36
|
"""
|
37
37
|
The task `with_period' does not exist.
|
38
38
|
|
39
|
+
"""
|
40
|
+
|
41
|
+
Scenario: mirror Rake task 'my_namespace' with its description
|
42
|
+
Given a full-featured Rakefile
|
43
|
+
And a Capfile with:
|
44
|
+
"""
|
45
|
+
Cape do
|
46
|
+
mirror_rake_tasks :my_namespace
|
47
|
+
end
|
48
|
+
"""
|
49
|
+
When I run `cap -e my_namespace`
|
50
|
+
Then the output should contain exactly:
|
51
|
+
"""
|
52
|
+
------------------------------------------------------------
|
53
|
+
cap my_namespace
|
54
|
+
------------------------------------------------------------
|
55
|
+
A task that shadows a namespace.
|
56
|
+
|
57
|
+
|
39
58
|
"""
|
40
59
|
|
41
60
|
Scenario: mirror Rake task 'my_namespace:in_a_namespace' with its description
|
@@ -0,0 +1,199 @@
|
|
1
|
+
Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and valid options, and with environment variables
|
2
|
+
|
3
|
+
In order to include Rake tasks with descriptions in my Capistrano recipes,
|
4
|
+
As a developer using Cape,
|
5
|
+
I want to use the Cape DSL.
|
6
|
+
|
7
|
+
Scenario: mirror all non-hidden Rake tasks with the specified options
|
8
|
+
Given a full-featured Rakefile
|
9
|
+
And a Capfile with:
|
10
|
+
"""
|
11
|
+
Cape do
|
12
|
+
mirror_rake_tasks :roles => :app do |env|
|
13
|
+
env['RAILS_ENV'] = rails_env
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I run `cap -T`
|
18
|
+
Then the output should contain:
|
19
|
+
"""
|
20
|
+
cap with_period # Ends with period.
|
21
|
+
"""
|
22
|
+
And the output should contain:
|
23
|
+
"""
|
24
|
+
cap without_period # Ends without period.
|
25
|
+
"""
|
26
|
+
And the output should contain:
|
27
|
+
"""
|
28
|
+
cap long # My long task -- it has a ve...
|
29
|
+
"""
|
30
|
+
And the output should contain:
|
31
|
+
"""
|
32
|
+
cap with_one_arg # My task with one argument.
|
33
|
+
"""
|
34
|
+
And the output should contain:
|
35
|
+
"""
|
36
|
+
cap my_namespace # A task that shadows a names...
|
37
|
+
"""
|
38
|
+
And the output should contain:
|
39
|
+
"""
|
40
|
+
cap my_namespace:in_a_namespace # My task in a namespace.
|
41
|
+
"""
|
42
|
+
And the output should contain:
|
43
|
+
"""
|
44
|
+
cap my_namespace:my_nested_namespace:in_a_nested_namespace # My task in a nested namespace.
|
45
|
+
"""
|
46
|
+
And the output should contain:
|
47
|
+
"""
|
48
|
+
cap with_two_args # My task with two arguments.
|
49
|
+
"""
|
50
|
+
And the output should contain:
|
51
|
+
"""
|
52
|
+
cap with_three_args # My task with three arguments.
|
53
|
+
"""
|
54
|
+
And the output should not contain "cap hidden_task"
|
55
|
+
|
56
|
+
Scenario: mirror Rake task 'with_period' with its description
|
57
|
+
Given a full-featured Rakefile
|
58
|
+
And a Capfile with:
|
59
|
+
"""
|
60
|
+
Cape do
|
61
|
+
mirror_rake_tasks :roles => :app do |env|
|
62
|
+
env['RAILS_ENV'] = rails_env
|
63
|
+
end
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
When I run `cap -e with_period`
|
67
|
+
Then the output should contain exactly:
|
68
|
+
"""
|
69
|
+
------------------------------------------------------------
|
70
|
+
cap with_period
|
71
|
+
------------------------------------------------------------
|
72
|
+
Ends with period.
|
73
|
+
|
74
|
+
|
75
|
+
"""
|
76
|
+
|
77
|
+
Scenario: mirror Rake task 'with_period' with its implementation
|
78
|
+
Given a full-featured Rakefile
|
79
|
+
And a Capfile with:
|
80
|
+
"""
|
81
|
+
set :current_path, '/path/to/current/deployed/application'
|
82
|
+
set :rails_env, 'production'
|
83
|
+
|
84
|
+
Cape do
|
85
|
+
mirror_rake_tasks :roles => :app do |env|
|
86
|
+
env['RAILS_ENV'] = rails_env
|
87
|
+
end
|
88
|
+
end
|
89
|
+
"""
|
90
|
+
When I run `cap with_period`
|
91
|
+
Then the output should contain:
|
92
|
+
"""
|
93
|
+
* executing `with_period'
|
94
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period RAILS_ENV=\"production\""
|
95
|
+
`with_period' is only run for servers matching {:roles=>:app}, but no servers matched
|
96
|
+
"""
|
97
|
+
|
98
|
+
Scenario: mirror Rake task 'with_one_arg' with its description
|
99
|
+
Given a full-featured Rakefile
|
100
|
+
And a Capfile with:
|
101
|
+
"""
|
102
|
+
Cape do
|
103
|
+
mirror_rake_tasks :roles => :app do |env|
|
104
|
+
env['RAILS_ENV'] = rails_env
|
105
|
+
end
|
106
|
+
end
|
107
|
+
"""
|
108
|
+
When I run `cap -e with_one_arg`
|
109
|
+
Then the output should contain exactly:
|
110
|
+
"""
|
111
|
+
------------------------------------------------------------
|
112
|
+
cap with_one_arg
|
113
|
+
------------------------------------------------------------
|
114
|
+
My task with one argument.
|
115
|
+
|
116
|
+
Set environment variable THE_ARG if you want to pass a Rake task argument.
|
117
|
+
|
118
|
+
|
119
|
+
"""
|
120
|
+
|
121
|
+
Scenario: mirror Rake task 'my_namespace:in_a_namespace' with its description
|
122
|
+
Given a full-featured Rakefile
|
123
|
+
And a Capfile with:
|
124
|
+
"""
|
125
|
+
Cape do
|
126
|
+
mirror_rake_tasks :roles => :app do |env|
|
127
|
+
env['RAILS_ENV'] = rails_env
|
128
|
+
end
|
129
|
+
end
|
130
|
+
"""
|
131
|
+
When I run `cap -e my_namespace:in_a_namespace`
|
132
|
+
Then the output should contain exactly:
|
133
|
+
"""
|
134
|
+
------------------------------------------------------------
|
135
|
+
cap my_namespace:in_a_namespace
|
136
|
+
------------------------------------------------------------
|
137
|
+
My task in a namespace.
|
138
|
+
|
139
|
+
|
140
|
+
"""
|
141
|
+
|
142
|
+
Scenario: mirror Rake task 'with_three_args' with its implementation
|
143
|
+
Given a full-featured Rakefile
|
144
|
+
And a Capfile with:
|
145
|
+
"""
|
146
|
+
set :current_path, '/path/to/current/deployed/application'
|
147
|
+
set :rails_env, 'production'
|
148
|
+
|
149
|
+
Cape do
|
150
|
+
mirror_rake_tasks :roles => :app do |env|
|
151
|
+
env['RAILS_ENV'] = rails_env
|
152
|
+
end
|
153
|
+
end
|
154
|
+
"""
|
155
|
+
When I run `cap with_three_args AN_ARG1="a value for an_arg1" AN_ARG2="a value for an_arg2" AN_ARG3="a value for an_arg3"`
|
156
|
+
Then the output should contain:
|
157
|
+
"""
|
158
|
+
* executing `with_three_args'
|
159
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_three_args[\"a value for an_arg1\",\"a value for an_arg2\",\"a value for an_arg3\"] RAILS_ENV=\"production\""
|
160
|
+
`with_three_args' is only run for servers matching {:roles=>:app}, but no servers matched
|
161
|
+
"""
|
162
|
+
|
163
|
+
Scenario: mirror Rake task 'with_three_args' with its implementation not enforcing arguments
|
164
|
+
Given a full-featured Rakefile
|
165
|
+
And a Capfile with:
|
166
|
+
"""
|
167
|
+
set :current_path, '/path/to/current/deployed/application'
|
168
|
+
set :rails_env, 'production'
|
169
|
+
|
170
|
+
Cape do
|
171
|
+
mirror_rake_tasks :roles => :app do |env|
|
172
|
+
env['RAILS_ENV'] = rails_env
|
173
|
+
end
|
174
|
+
end
|
175
|
+
"""
|
176
|
+
When I run `cap with_three_args AN_ARG2="a value for an_arg2"`
|
177
|
+
Then the output should contain:
|
178
|
+
"""
|
179
|
+
* executing `with_three_args'
|
180
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_three_args[,\"a value for an_arg2\",] RAILS_ENV=\"production\""
|
181
|
+
`with_three_args' is only run for servers matching {:roles=>:app}, but no servers matched
|
182
|
+
"""
|
183
|
+
|
184
|
+
Scenario: do not mirror Rake task 'hidden_task'
|
185
|
+
Given a full-featured Rakefile
|
186
|
+
And a Capfile with:
|
187
|
+
"""
|
188
|
+
Cape do
|
189
|
+
mirror_rake_tasks :roles => :app do |env|
|
190
|
+
env['RAILS_ENV'] = rails_env
|
191
|
+
end
|
192
|
+
end
|
193
|
+
"""
|
194
|
+
When I run `cap -e hidden_task`
|
195
|
+
Then the output should contain exactly:
|
196
|
+
"""
|
197
|
+
The task `hidden_task' does not exist.
|
198
|
+
|
199
|
+
"""
|
@@ -0,0 +1,90 @@
|
|
1
|
+
Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and valid options, and with environment variables
|
2
|
+
|
3
|
+
In order to include Rake tasks with descriptions in my Capistrano recipes,
|
4
|
+
As a developer using Cape,
|
5
|
+
I want to use the Cape DSL.
|
6
|
+
|
7
|
+
Scenario: mirror all non-hidden Rake tasks with the specified options
|
8
|
+
Given a full-featured Rakefile
|
9
|
+
And a Capfile with:
|
10
|
+
"""
|
11
|
+
Cape do
|
12
|
+
mirror_rake_tasks :roles => :app
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
When I run `cap -T`
|
16
|
+
Then the output should contain:
|
17
|
+
"""
|
18
|
+
cap with_period # Ends with period.
|
19
|
+
"""
|
20
|
+
And the output should contain:
|
21
|
+
"""
|
22
|
+
cap without_period # Ends without period.
|
23
|
+
"""
|
24
|
+
And the output should contain:
|
25
|
+
"""
|
26
|
+
cap long # My long task -- it has a ve...
|
27
|
+
"""
|
28
|
+
And the output should contain:
|
29
|
+
"""
|
30
|
+
cap with_one_arg # My task with one argument.
|
31
|
+
"""
|
32
|
+
And the output should contain:
|
33
|
+
"""
|
34
|
+
cap my_namespace # A task that shadows a names...
|
35
|
+
"""
|
36
|
+
And the output should contain:
|
37
|
+
"""
|
38
|
+
cap my_namespace:in_a_namespace # My task in a namespace.
|
39
|
+
"""
|
40
|
+
And the output should contain:
|
41
|
+
"""
|
42
|
+
cap my_namespace:my_nested_namespace:in_a_nested_namespace # My task in a nested namespace.
|
43
|
+
"""
|
44
|
+
And the output should contain:
|
45
|
+
"""
|
46
|
+
cap with_two_args # My task with two arguments.
|
47
|
+
"""
|
48
|
+
And the output should contain:
|
49
|
+
"""
|
50
|
+
cap with_three_args # My task with three arguments.
|
51
|
+
"""
|
52
|
+
And the output should not contain "cap hidden_task"
|
53
|
+
|
54
|
+
Scenario: mirror Rake task 'with_period' with its description
|
55
|
+
Given a full-featured Rakefile
|
56
|
+
And a Capfile with:
|
57
|
+
"""
|
58
|
+
Cape do
|
59
|
+
mirror_rake_tasks :roles => :app
|
60
|
+
end
|
61
|
+
"""
|
62
|
+
When I run `cap -e with_period`
|
63
|
+
Then the output should contain exactly:
|
64
|
+
"""
|
65
|
+
------------------------------------------------------------
|
66
|
+
cap with_period
|
67
|
+
------------------------------------------------------------
|
68
|
+
Ends with period.
|
69
|
+
|
70
|
+
|
71
|
+
"""
|
72
|
+
|
73
|
+
Scenario: mirror Rake task 'with_period' with its implementation
|
74
|
+
Given a full-featured Rakefile
|
75
|
+
And a Capfile with:
|
76
|
+
"""
|
77
|
+
set :current_path, '/path/to/current/deployed/application'
|
78
|
+
set :rails_env, 'production'
|
79
|
+
|
80
|
+
Cape do
|
81
|
+
mirror_rake_tasks :roles => :app
|
82
|
+
end
|
83
|
+
"""
|
84
|
+
When I run `cap with_period`
|
85
|
+
Then the output should contain:
|
86
|
+
"""
|
87
|
+
* executing `with_period'
|
88
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period"
|
89
|
+
`with_period' is only run for servers matching {:roles=>:app}, but no servers matched
|
90
|
+
"""
|
@@ -29,6 +29,10 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
29
29
|
"""
|
30
30
|
cap with_one_arg # My task with one argument.
|
31
31
|
"""
|
32
|
+
And the output should contain:
|
33
|
+
"""
|
34
|
+
cap my_namespace # A task that shadows a names...
|
35
|
+
"""
|
32
36
|
And the output should contain:
|
33
37
|
"""
|
34
38
|
cap my_namespace:in_a_namespace # My task in a namespace.
|
@@ -79,6 +83,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
79
83
|
When I run `cap with_period`
|
80
84
|
Then the output should contain:
|
81
85
|
"""
|
86
|
+
* executing `with_period'
|
82
87
|
* executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period"
|
83
88
|
"""
|
84
89
|
|
@@ -138,11 +143,47 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
138
143
|
------------------------------------------------------------
|
139
144
|
My task with one argument.
|
140
145
|
|
141
|
-
Set environment variable THE_ARG to pass a Rake task argument.
|
146
|
+
Set environment variable THE_ARG if you want to pass a Rake task argument.
|
142
147
|
|
143
148
|
|
144
149
|
"""
|
145
150
|
|
151
|
+
Scenario: mirror Rake task 'my_namespace' with its description
|
152
|
+
Given a full-featured Rakefile
|
153
|
+
And a Capfile with:
|
154
|
+
"""
|
155
|
+
Cape do
|
156
|
+
mirror_rake_tasks
|
157
|
+
end
|
158
|
+
"""
|
159
|
+
When I run `cap -e my_namespace`
|
160
|
+
Then the output should contain exactly:
|
161
|
+
"""
|
162
|
+
------------------------------------------------------------
|
163
|
+
cap my_namespace
|
164
|
+
------------------------------------------------------------
|
165
|
+
A task that shadows a namespace.
|
166
|
+
|
167
|
+
|
168
|
+
"""
|
169
|
+
|
170
|
+
Scenario: mirror Rake task 'my_namespace' with its implementation
|
171
|
+
Given a full-featured Rakefile
|
172
|
+
And a Capfile with:
|
173
|
+
"""
|
174
|
+
set :current_path, '/path/to/current/deployed/application'
|
175
|
+
|
176
|
+
Cape do
|
177
|
+
mirror_rake_tasks
|
178
|
+
end
|
179
|
+
"""
|
180
|
+
When I run `cap my_namespace`
|
181
|
+
Then the output should contain:
|
182
|
+
"""
|
183
|
+
* executing `my_namespace'
|
184
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env rake my_namespace"
|
185
|
+
"""
|
186
|
+
|
146
187
|
Scenario: mirror Rake task 'my_namespace:in_a_namespace' with its description
|
147
188
|
Given a full-featured Rakefile
|
148
189
|
And a Capfile with:
|
@@ -194,7 +235,8 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
194
235
|
When I run `cap my_namespace:my_nested_namespace:in_a_nested_namespace`
|
195
236
|
Then the output should contain:
|
196
237
|
"""
|
197
|
-
|
238
|
+
* executing `my_namespace:my_nested_namespace:in_a_nested_namespace'
|
239
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env rake my_namespace:my_nested_namespace:in_a_nested_namespace"
|
198
240
|
"""
|
199
241
|
|
200
242
|
Scenario: mirror Rake task 'with_two_args' with its description
|
@@ -213,7 +255,8 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
213
255
|
------------------------------------------------------------
|
214
256
|
My task with two arguments.
|
215
257
|
|
216
|
-
Set environment variables MY_ARG1 and MY_ARG2 to pass Rake task
|
258
|
+
Set environment variables MY_ARG1 and MY_ARG2 if you want to pass Rake task
|
259
|
+
arguments.
|
217
260
|
|
218
261
|
|
219
262
|
"""
|
@@ -234,8 +277,8 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
234
277
|
------------------------------------------------------------
|
235
278
|
My task with three arguments.
|
236
279
|
|
237
|
-
Set environment variables AN_ARG1, AN_ARG2, and AN_ARG3 to pass Rake
|
238
|
-
arguments.
|
280
|
+
Set environment variables AN_ARG1, AN_ARG2, and AN_ARG3 if you want to pass Rake
|
281
|
+
task arguments.
|
239
282
|
|
240
283
|
|
241
284
|
"""
|
@@ -8,10 +8,11 @@ Feature: The #local_rake_executable and #remote_rake_executable DSL attributes
|
|
8
8
|
Given a full-featured Rakefile
|
9
9
|
And a Capfile with:
|
10
10
|
"""
|
11
|
+
Cape.local_rake_executable = 'echo "rake this-comes-from-overridden-rake # This comes from overridden Rake" #'
|
12
|
+
|
11
13
|
Cape do
|
12
|
-
|
13
|
-
$stdout.puts "We
|
14
|
-
$stdout.puts "We left the remote Rake executable as #{self.remote_rake_executable.inspect}."
|
14
|
+
$stdout.puts "We changed the local Rake executable to #{local_rake_executable.inspect}."
|
15
|
+
$stdout.puts "We left the remote Rake executable as #{remote_rake_executable.inspect}."
|
15
16
|
each_rake_task do |t|
|
16
17
|
$stdout.puts '', "Name: #{t[:name].inspect}"
|
17
18
|
if t[:parameters]
|
@@ -44,10 +45,12 @@ Feature: The #local_rake_executable and #remote_rake_executable DSL attributes
|
|
44
45
|
And a Capfile with:
|
45
46
|
"""
|
46
47
|
set :current_path, '/path/to/current/deployed/application'
|
48
|
+
|
49
|
+
Cape.remote_rake_executable = 'echo "This comes from overridden Rake" #'
|
50
|
+
|
47
51
|
Cape do
|
48
|
-
|
49
|
-
$stdout.puts "We
|
50
|
-
$stdout.puts "We left the local Rake executable as #{self.local_rake_executable.inspect}."
|
52
|
+
$stdout.puts "We changed the remote Rake executable to #{remote_rake_executable.inspect}."
|
53
|
+
$stdout.puts "We left the local Rake executable as #{local_rake_executable.inspect}."
|
51
54
|
mirror_rake_tasks
|
52
55
|
end
|
53
56
|
"""
|
@@ -62,5 +65,6 @@ Feature: The #local_rake_executable and #remote_rake_executable DSL attributes
|
|
62
65
|
"""
|
63
66
|
And the output should contain:
|
64
67
|
"""
|
68
|
+
* executing `with_period'
|
65
69
|
* executing "cd /path/to/current/deployed/application && echo \"This comes from overridden Rake\" # with_period"
|
66
70
|
"""
|