whenever 0.9.2 → 0.10.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +17 -7
- data/CHANGELOG.md +63 -0
- data/Gemfile +0 -5
- data/LICENSE +1 -1
- data/README.md +101 -18
- data/Rakefile +3 -10
- data/bin/whenever +3 -0
- data/bin/wheneverize +8 -5
- data/gemfiles/activesupport4.1.gemfile +5 -0
- data/gemfiles/activesupport4.2.gemfile +5 -0
- data/lib/whenever/capistrano/v2/recipes.rb +4 -3
- data/lib/whenever/capistrano/v3/tasks/whenever.rake +20 -7
- data/lib/whenever/capistrano.rb +1 -1
- data/lib/whenever/command_line.rb +49 -28
- data/lib/whenever/cron.rb +43 -21
- data/lib/whenever/job.rb +4 -3
- data/lib/whenever/job_list.rb +54 -24
- data/lib/whenever/numeric.rb +13 -0
- data/lib/whenever/numeric_seconds.rb +48 -0
- data/lib/whenever/os.rb +7 -0
- data/lib/whenever/setup.rb +5 -1
- data/lib/whenever/version.rb +1 -1
- data/lib/whenever.rb +15 -14
- data/test/functional/command_line_test.rb +379 -255
- data/test/functional/output_at_test.rb +227 -249
- data/test/functional/output_default_defined_jobs_test.rb +239 -288
- data/test/functional/output_defined_job_test.rb +65 -91
- data/test/functional/output_env_test.rb +22 -26
- data/test/functional/output_jobs_for_roles_test.rb +46 -66
- data/test/functional/output_jobs_with_mailto_test.rb +168 -0
- data/test/functional/output_redirection_test.rb +231 -309
- data/test/test_case.rb +32 -0
- data/test/test_helper.rb +44 -15
- data/test/unit/capistrano_support_test.rb +126 -148
- data/test/unit/cron_test.rb +327 -210
- data/test/unit/executable_test.rb +142 -0
- data/test/unit/job_test.rb +111 -121
- data/whenever.gemspec +5 -4
- metadata +37 -28
- data/lib/whenever/tasks/whenever.rake +0 -43
|
@@ -1,345 +1,296 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'test_helper'
|
|
2
2
|
|
|
3
|
-
class OutputDefaultDefinedJobsTest <
|
|
3
|
+
class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
4
4
|
|
|
5
5
|
# command
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
file
|
|
16
|
-
end
|
|
7
|
+
test "A plain command with the job template set to nil" do
|
|
8
|
+
output = Whenever.cron \
|
|
9
|
+
<<-file
|
|
10
|
+
set :job_template, nil
|
|
11
|
+
every 2.hours do
|
|
12
|
+
command "blahblah"
|
|
13
|
+
end
|
|
14
|
+
file
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
assert_match /^.+ .+ .+ .+ blahblah$/, @output
|
|
20
|
-
end
|
|
16
|
+
assert_match(/^.+ .+ .+ .+ blahblah$/, output)
|
|
21
17
|
end
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
file
|
|
31
|
-
end
|
|
19
|
+
test "A plain command with no job template set" do
|
|
20
|
+
output = Whenever.cron \
|
|
21
|
+
<<-file
|
|
22
|
+
every 2.hours do
|
|
23
|
+
command "blahblah"
|
|
24
|
+
end
|
|
25
|
+
file
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, @output
|
|
35
|
-
end
|
|
27
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, output)
|
|
36
28
|
end
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
should "output the command using that job_template" do
|
|
51
|
-
assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'cd \/tmp \&\& blahblah'$/, @output
|
|
52
|
-
end
|
|
30
|
+
test "A plain command with a job_template using a normal parameter" do
|
|
31
|
+
output = Whenever.cron \
|
|
32
|
+
<<-file
|
|
33
|
+
set :job_template, "/bin/bash -l -c 'cd :path && :job'"
|
|
34
|
+
every 2.hours do
|
|
35
|
+
set :path, "/tmp"
|
|
36
|
+
command "blahblah"
|
|
37
|
+
end
|
|
38
|
+
file
|
|
39
|
+
|
|
40
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/bash -l -c 'cd \/tmp \&\& blahblah'$/, output)
|
|
53
41
|
end
|
|
54
42
|
|
|
43
|
+
test "A plain command that overrides the job_template set" do
|
|
44
|
+
output = Whenever.cron \
|
|
45
|
+
<<-file
|
|
46
|
+
set :job_template, "/bin/bash -l -c ':job'"
|
|
47
|
+
every 2.hours do
|
|
48
|
+
command "blahblah", :job_template => "/bin/sh -l -c ':job'"
|
|
49
|
+
end
|
|
50
|
+
file
|
|
55
51
|
|
|
56
|
-
context "A plain command that overrides the job_template set" do
|
|
57
|
-
setup do
|
|
58
|
-
@output = Whenever.cron \
|
|
59
|
-
<<-file
|
|
60
|
-
set :job_template, "/bin/bash -l -c ':job'"
|
|
61
|
-
every 2.hours do
|
|
62
|
-
command "blahblah", :job_template => "/bin/sh -l -c ':job'"
|
|
63
|
-
end
|
|
64
|
-
file
|
|
65
|
-
end
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
assert_no_match /bash/, @output
|
|
70
|
-
end
|
|
53
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, output)
|
|
54
|
+
assert_no_match(/bash/, output)
|
|
71
55
|
end
|
|
72
56
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
file
|
|
83
|
-
end
|
|
57
|
+
test "A plain command that overrides the job_template set using a parameter" do
|
|
58
|
+
output = Whenever.cron \
|
|
59
|
+
<<-file
|
|
60
|
+
set :job_template, "/bin/bash -l -c 'cd :path && :job'"
|
|
61
|
+
every 2.hours do
|
|
62
|
+
set :path, "/tmp"
|
|
63
|
+
command "blahblah", :job_template => "/bin/sh -l -c 'cd :path && :job'"
|
|
64
|
+
end
|
|
65
|
+
file
|
|
84
66
|
|
|
85
|
-
should "output the command using that job_template" do
|
|
86
|
-
assert_match /^.+ .+ .+ .+ \/bin\/sh -l -c 'cd \/tmp && blahblah'$/, @output
|
|
87
|
-
assert_no_match /bash/, @output
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
67
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Whenever.expects(:path).at_least_once.returns('/what/you/want')
|
|
94
|
-
@output = Whenever.cron \
|
|
95
|
-
<<-file
|
|
96
|
-
set :job_template, nil
|
|
97
|
-
if environment == 'production' && path == '/what/you/want'
|
|
98
|
-
every 2.hours do
|
|
99
|
-
command "blahblah"
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
file
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
should "output the command" do
|
|
106
|
-
assert_match /blahblah/, @output
|
|
107
|
-
end
|
|
68
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/sh -l -c 'cd \/tmp && blahblah'$/, output)
|
|
69
|
+
assert_no_match(/bash/, output)
|
|
108
70
|
end
|
|
109
71
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
set :job_template, nil
|
|
117
|
-
set :path, '/my/path'
|
|
72
|
+
test "A plain command that is conditional on default environent and path" do
|
|
73
|
+
Whenever.expects(:path).at_least_once.returns('/what/you/want')
|
|
74
|
+
output = Whenever.cron \
|
|
75
|
+
<<-file
|
|
76
|
+
set :job_template, nil
|
|
77
|
+
if environment == 'production' && path == '/what/you/want'
|
|
118
78
|
every 2.hours do
|
|
119
|
-
|
|
79
|
+
command "blahblah"
|
|
120
80
|
end
|
|
121
|
-
|
|
122
|
-
|
|
81
|
+
end
|
|
82
|
+
file
|
|
123
83
|
|
|
124
|
-
|
|
125
|
-
assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), @output
|
|
126
|
-
end
|
|
84
|
+
assert_match(/blahblah/, output)
|
|
127
85
|
end
|
|
128
86
|
|
|
129
|
-
|
|
130
|
-
setup do
|
|
131
|
-
@output = Whenever.cron \
|
|
132
|
-
<<-file
|
|
133
|
-
set :job_template, nil
|
|
134
|
-
set :path, '/my/path'
|
|
135
|
-
every 2.hours do
|
|
136
|
-
runner "blahblah", :path => '/some/other/path'
|
|
137
|
-
end
|
|
138
|
-
file
|
|
139
|
-
end
|
|
87
|
+
# runner
|
|
140
88
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
89
|
+
test "A runner with path set" do
|
|
90
|
+
output = Whenever.cron \
|
|
91
|
+
<<-file
|
|
92
|
+
set :job_template, nil
|
|
93
|
+
set :path, '/my/path'
|
|
94
|
+
every 2.hours do
|
|
95
|
+
runner 'blahblah'
|
|
96
|
+
end
|
|
97
|
+
file
|
|
98
|
+
|
|
99
|
+
assert_match two_hours + %( cd /my/path && bundle exec script/runner -e production 'blahblah'), output
|
|
144
100
|
end
|
|
145
101
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
102
|
+
test "A runner that overrides the path set" do
|
|
103
|
+
output = Whenever.cron \
|
|
104
|
+
<<-file
|
|
105
|
+
set :job_template, nil
|
|
106
|
+
set :path, '/my/path'
|
|
107
|
+
every 2.hours do
|
|
108
|
+
runner "blahblah", :path => '/some/other/path'
|
|
109
|
+
end
|
|
110
|
+
file
|
|
111
|
+
|
|
112
|
+
assert_match two_hours + %( cd /some/other/path && bundle exec script/runner -e production 'blahblah'), output
|
|
113
|
+
end
|
|
158
114
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
115
|
+
test "A runner for a non-bundler app" do
|
|
116
|
+
Whenever.expects(:bundler?).returns(false)
|
|
117
|
+
output = Whenever.cron \
|
|
118
|
+
<<-file
|
|
119
|
+
set :job_template, nil
|
|
120
|
+
set :path, '/my/path'
|
|
121
|
+
every 2.hours do
|
|
122
|
+
runner 'blahblah'
|
|
123
|
+
end
|
|
124
|
+
file
|
|
125
|
+
|
|
126
|
+
assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), output
|
|
162
127
|
end
|
|
163
128
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
129
|
+
test "A runner for an app with bin/rails" do
|
|
130
|
+
Whenever.expects(:path).at_least_once.returns('/my/path')
|
|
131
|
+
Whenever.expects(:bin_rails?).returns(true)
|
|
132
|
+
output = Whenever.cron \
|
|
133
|
+
<<-file
|
|
134
|
+
set :job_template, nil
|
|
135
|
+
every 2.hours do
|
|
136
|
+
runner 'blahblah'
|
|
137
|
+
end
|
|
138
|
+
file
|
|
139
|
+
|
|
140
|
+
assert_match two_hours + %( cd /my/path && bin/rails runner -e production 'blahblah'), output
|
|
141
|
+
end
|
|
176
142
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
143
|
+
test "A runner for an app with script/rails" do
|
|
144
|
+
Whenever.expects(:path).at_least_once.returns('/my/path')
|
|
145
|
+
Whenever.expects(:script_rails?).returns(true)
|
|
146
|
+
output = Whenever.cron \
|
|
147
|
+
<<-file
|
|
148
|
+
set :job_template, nil
|
|
149
|
+
every 2.hours do
|
|
150
|
+
runner 'blahblah'
|
|
151
|
+
end
|
|
152
|
+
file
|
|
153
|
+
|
|
154
|
+
assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), output
|
|
180
155
|
end
|
|
181
156
|
|
|
182
157
|
# rake
|
|
183
158
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
should "output the rake command using that path" do
|
|
197
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah --silent', @output
|
|
198
|
-
end
|
|
159
|
+
test "A rake command with path set" do
|
|
160
|
+
output = Whenever.cron \
|
|
161
|
+
<<-file
|
|
162
|
+
set :job_template, nil
|
|
163
|
+
set :path, '/my/path'
|
|
164
|
+
every 2.hours do
|
|
165
|
+
rake "blahblah"
|
|
166
|
+
end
|
|
167
|
+
file
|
|
168
|
+
|
|
169
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
|
|
199
170
|
end
|
|
200
171
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
should "not use invoke through bundler" do
|
|
215
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', @output
|
|
216
|
-
end
|
|
172
|
+
test "A rake command with arguments" do
|
|
173
|
+
output = Whenever.cron \
|
|
174
|
+
<<-file
|
|
175
|
+
set :job_template, nil
|
|
176
|
+
set :path, '/my/path'
|
|
177
|
+
every 2.hours do
|
|
178
|
+
rake "blahblah[foobar]"
|
|
179
|
+
end
|
|
180
|
+
file
|
|
181
|
+
|
|
182
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah[foobar] --silent', output
|
|
217
183
|
end
|
|
218
184
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
should "output the rake command using that path" do
|
|
232
|
-
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec rake blahblah --silent', @output
|
|
233
|
-
end
|
|
185
|
+
test "A rake for a non-bundler app" do
|
|
186
|
+
Whenever.expects(:path).at_least_once.returns('/my/path')
|
|
187
|
+
Whenever.expects(:bundler?).returns(false)
|
|
188
|
+
output = Whenever.cron \
|
|
189
|
+
<<-file
|
|
190
|
+
set :job_template, nil
|
|
191
|
+
every 2.hours do
|
|
192
|
+
rake 'blahblah'
|
|
193
|
+
end
|
|
194
|
+
file
|
|
195
|
+
|
|
196
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', output
|
|
234
197
|
end
|
|
235
198
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
should "output the rake command using that environment variable" do
|
|
250
|
-
assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec rake blahblah --silent', @output
|
|
251
|
-
end
|
|
199
|
+
test "A rake command that overrides the path set" do
|
|
200
|
+
output = Whenever.cron \
|
|
201
|
+
<<-file
|
|
202
|
+
set :job_template, nil
|
|
203
|
+
set :path, '/my/path'
|
|
204
|
+
every 2.hours do
|
|
205
|
+
rake "blahblah", :path => '/some/other/path'
|
|
206
|
+
end
|
|
207
|
+
file
|
|
208
|
+
|
|
209
|
+
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
|
|
252
210
|
end
|
|
253
211
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
212
|
+
test "A rake command that sets the environment variable" do
|
|
213
|
+
output = Whenever.cron \
|
|
214
|
+
<<-file
|
|
215
|
+
set :job_template, nil
|
|
216
|
+
set :path, '/my/path'
|
|
217
|
+
set :environment_variable, 'RAKE_ENV'
|
|
218
|
+
every 2.hours do
|
|
219
|
+
rake "blahblah"
|
|
220
|
+
end
|
|
221
|
+
file
|
|
222
|
+
|
|
223
|
+
assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec rake blahblah --silent', output
|
|
224
|
+
end
|
|
266
225
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
226
|
+
test "A rake command that overrides the environment variable" do
|
|
227
|
+
output = Whenever.cron \
|
|
228
|
+
<<-file
|
|
229
|
+
set :job_template, nil
|
|
230
|
+
set :path, '/my/path'
|
|
231
|
+
set :environment_variable, 'RAKE_ENV'
|
|
232
|
+
every 2.hours do
|
|
233
|
+
rake "blahblah", :environment_variable => 'SOME_ENV'
|
|
234
|
+
end
|
|
235
|
+
file
|
|
236
|
+
|
|
237
|
+
assert_match two_hours + ' cd /my/path && SOME_ENV=production bundle exec rake blahblah --silent', output
|
|
270
238
|
end
|
|
271
239
|
|
|
272
240
|
# script
|
|
273
241
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
should "output the script command using that path" do
|
|
287
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec script/blahblah', @output
|
|
288
|
-
end
|
|
242
|
+
test "A script command with path set" do
|
|
243
|
+
output = Whenever.cron \
|
|
244
|
+
<<-file
|
|
245
|
+
set :job_template, nil
|
|
246
|
+
set :path, '/my/path'
|
|
247
|
+
every 2.hours do
|
|
248
|
+
script "blahblah"
|
|
249
|
+
end
|
|
250
|
+
file
|
|
251
|
+
|
|
252
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec script/blahblah', output
|
|
289
253
|
end
|
|
290
254
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
should "not use invoke through bundler" do
|
|
305
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=production script/blahblah', @output
|
|
306
|
-
end
|
|
255
|
+
test "A script command for a non-bundler app" do
|
|
256
|
+
Whenever.expects(:path).at_least_once.returns('/my/path')
|
|
257
|
+
Whenever.expects(:bundler?).returns(false)
|
|
258
|
+
output = Whenever.cron \
|
|
259
|
+
<<-file
|
|
260
|
+
set :job_template, nil
|
|
261
|
+
every 2.hours do
|
|
262
|
+
script 'blahblah'
|
|
263
|
+
end
|
|
264
|
+
file
|
|
265
|
+
|
|
266
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production script/blahblah', output
|
|
307
267
|
end
|
|
308
268
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
should "output the script command using that path" do
|
|
323
|
-
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec script/blahblah >> /log/file 2>&1', @output
|
|
324
|
-
end
|
|
269
|
+
test "A script command that uses output" do
|
|
270
|
+
output = Whenever.cron \
|
|
271
|
+
<<-file
|
|
272
|
+
set :job_template, nil
|
|
273
|
+
set :output, '/log/file'
|
|
274
|
+
set :path, '/my/path'
|
|
275
|
+
every 2.hours do
|
|
276
|
+
script "blahblah", :path => '/some/other/path'
|
|
277
|
+
end
|
|
278
|
+
file
|
|
279
|
+
|
|
280
|
+
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec script/blahblah >> /log/file 2>&1', output
|
|
325
281
|
end
|
|
326
282
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
should "output the script command using that environment variable" do
|
|
341
|
-
assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec script/blahblah', @output
|
|
342
|
-
end
|
|
283
|
+
test "A script command that uses an environment variable" do
|
|
284
|
+
output = Whenever.cron \
|
|
285
|
+
<<-file
|
|
286
|
+
set :job_template, nil
|
|
287
|
+
set :environment_variable, 'RAKE_ENV'
|
|
288
|
+
set :path, '/my/path'
|
|
289
|
+
every 2.hours do
|
|
290
|
+
script "blahblah"
|
|
291
|
+
end
|
|
292
|
+
file
|
|
293
|
+
|
|
294
|
+
assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec script/blahblah', output
|
|
343
295
|
end
|
|
344
|
-
|
|
345
296
|
end
|