whenever 0.8.2 → 1.0.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 +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +20 -7
- data/Appraisals +19 -0
- data/CHANGELOG.md +116 -3
- data/Gemfile +3 -3
- data/LICENSE +2 -2
- data/README.md +133 -32
- data/Rakefile +3 -10
- data/bin/whenever +3 -0
- data/bin/wheneverize +8 -5
- data/gemfiles/activesupport4.1.gemfile +7 -0
- data/gemfiles/activesupport4.2.gemfile +7 -0
- data/gemfiles/activesupport5.0.gemfile +7 -0
- data/gemfiles/activesupport5.1.gemfile +7 -0
- data/gemfiles/activesupport5.2.gemfile +7 -0
- data/lib/whenever/capistrano/v2/hooks.rb +8 -0
- data/lib/whenever/capistrano/{recipes.rb → v2/recipes.rb} +7 -13
- data/lib/whenever/capistrano/{support.rb → v2/support.rb} +12 -0
- data/lib/whenever/capistrano/v3/tasks/whenever.rake +56 -0
- data/lib/whenever/capistrano.rb +5 -6
- data/lib/whenever/command_line.rb +69 -48
- data/lib/whenever/cron.rb +54 -25
- data/lib/whenever/job.rb +13 -14
- 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/output_redirection.rb +1 -0
- data/lib/whenever/setup.rb +19 -15
- data/lib/whenever/version.rb +2 -2
- data/lib/whenever.rb +19 -14
- data/test/functional/command_line_test.rb +379 -243
- data/test/functional/output_at_test.rb +227 -249
- data/test/functional/output_default_defined_jobs_test.rb +251 -193
- 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 -65
- data/test/functional/output_jobs_with_mailto_test.rb +168 -0
- data/test/functional/output_redirection_test.rb +232 -291
- data/test/test_case.rb +32 -0
- data/test/test_helper.rb +44 -15
- data/test/unit/capistrano_support_test.rb +128 -134
- data/test/unit/cron_test.rb +373 -208
- data/test/unit/executable_test.rb +142 -0
- data/test/unit/job_test.rb +111 -117
- data/whenever.gemspec +7 -4
- metadata +63 -44
@@ -1,238 +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
|
-
should "output the command using that job_template" do
|
50
|
-
assert_match /^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, @output
|
51
|
-
assert_no_match /bash/, @output
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "A plain command that is conditional on default environent and path" do
|
56
|
-
setup do
|
57
|
-
Whenever.expects(:path).at_least_once.returns('/what/you/want')
|
58
|
-
@output = Whenever.cron \
|
59
|
-
<<-file
|
60
|
-
set :job_template, nil
|
61
|
-
if environment == 'production' && path == '/what/you/want'
|
62
|
-
every 2.hours do
|
63
|
-
command "blahblah"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
file
|
67
|
-
end
|
68
|
-
|
69
|
-
should "output the command" do
|
70
|
-
assert_match /blahblah/, @output
|
71
|
-
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)
|
72
41
|
end
|
73
42
|
|
74
|
-
|
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
|
75
51
|
|
76
|
-
context "A runner with path set" do
|
77
|
-
setup do
|
78
|
-
@output = Whenever.cron \
|
79
|
-
<<-file
|
80
|
-
set :job_template, nil
|
81
|
-
set :path, '/my/path'
|
82
|
-
every 2.hours do
|
83
|
-
runner 'blahblah'
|
84
|
-
end
|
85
|
-
file
|
86
|
-
end
|
87
52
|
|
88
|
-
|
89
|
-
|
90
|
-
end
|
53
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, output)
|
54
|
+
assert_no_match(/bash/, output)
|
91
55
|
end
|
92
56
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
set :path,
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
file
|
103
|
-
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
|
104
66
|
|
105
|
-
|
106
|
-
|
107
|
-
|
67
|
+
|
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
|
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'
|
117
78
|
every 2.hours do
|
118
|
-
|
79
|
+
command "blahblah"
|
119
80
|
end
|
120
|
-
|
121
|
-
|
81
|
+
end
|
82
|
+
file
|
122
83
|
|
123
|
-
|
124
|
-
assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), @output
|
125
|
-
end
|
84
|
+
assert_match(/blahblah/, output)
|
126
85
|
end
|
127
86
|
|
128
|
-
#
|
87
|
+
# runner
|
129
88
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
100
|
+
end
|
141
101
|
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
145
113
|
end
|
146
114
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
127
|
+
end
|
159
128
|
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|
163
141
|
end
|
164
142
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
155
|
+
end
|
176
156
|
|
177
|
-
|
178
|
-
|
179
|
-
|
157
|
+
# rake
|
158
|
+
|
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
|
180
170
|
end
|
181
171
|
|
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
|
183
|
+
end
|
182
184
|
|
183
|
-
|
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
|
197
|
+
end
|
184
198
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
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
|
210
|
+
end
|
196
211
|
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
200
224
|
end
|
201
225
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
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
|
238
|
+
end
|
214
239
|
|
215
|
-
|
216
|
-
|
217
|
-
|
240
|
+
# script
|
241
|
+
|
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
|
218
253
|
end
|
219
254
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
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
|
267
|
+
end
|
232
268
|
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
236
281
|
end
|
237
282
|
|
238
|
-
|
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
|
295
|
+
end
|
296
|
+
end
|
@@ -1,111 +1,85 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
class OutputDefinedJobTest <
|
3
|
+
class OutputDefinedJobTest < Whenever::TestCase
|
4
|
+
test "defined job with a :task" do
|
5
|
+
output = Whenever.cron \
|
6
|
+
<<-file
|
7
|
+
set :job_template, nil
|
8
|
+
job_type :some_job, "before :task after"
|
9
|
+
every 2.hours do
|
10
|
+
some_job "during"
|
11
|
+
end
|
12
|
+
file
|
4
13
|
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@output = Whenever.cron \
|
8
|
-
<<-file
|
9
|
-
set :job_template, nil
|
10
|
-
job_type :some_job, "before :task after"
|
11
|
-
every 2.hours do
|
12
|
-
some_job "during"
|
13
|
-
end
|
14
|
-
file
|
15
|
-
end
|
16
|
-
|
17
|
-
should "output the defined job with the task" do
|
18
|
-
assert_match /^.+ .+ .+ .+ before during after$/, @output
|
19
|
-
end
|
14
|
+
assert_match(/^.+ .+ .+ .+ before during after$/, output)
|
20
15
|
end
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
file
|
32
|
-
end
|
17
|
+
test "defined job with a :task and some options" do
|
18
|
+
output = Whenever.cron \
|
19
|
+
<<-file
|
20
|
+
set :job_template, nil
|
21
|
+
job_type :some_job, "before :task after :option1 :option2"
|
22
|
+
every 2.hours do
|
23
|
+
some_job "during", :option1 => 'happy', :option2 => 'birthday'
|
24
|
+
end
|
25
|
+
file
|
33
26
|
|
34
|
-
|
35
|
-
assert_match /^.+ .+ .+ .+ before during after happy birthday$/, @output
|
36
|
-
end
|
27
|
+
assert_match(/^.+ .+ .+ .+ before during after happy birthday$/, output)
|
37
28
|
end
|
38
29
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
file
|
50
|
-
end
|
30
|
+
test "defined job with a :task and an option where the option is set globally" do
|
31
|
+
output = Whenever.cron \
|
32
|
+
<<-file
|
33
|
+
set :job_template, nil
|
34
|
+
job_type :some_job, "before :task after :option1"
|
35
|
+
set :option1, 'happy'
|
36
|
+
every 2.hours do
|
37
|
+
some_job "during"
|
38
|
+
end
|
39
|
+
file
|
51
40
|
|
52
|
-
|
53
|
-
assert_match /^.+ .+ .+ .+ before during after happy$/, @output
|
54
|
-
end
|
41
|
+
assert_match(/^.+ .+ .+ .+ before during after happy$/, output)
|
55
42
|
end
|
56
43
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
file
|
68
|
-
end
|
44
|
+
test "defined job with a :task and an option where the option is set globally and locally" do
|
45
|
+
output = Whenever.cron \
|
46
|
+
<<-file
|
47
|
+
set :job_template, nil
|
48
|
+
job_type :some_job, "before :task after :option1"
|
49
|
+
set :option1, 'global'
|
50
|
+
every 2.hours do
|
51
|
+
some_job "during", :option1 => 'local'
|
52
|
+
end
|
53
|
+
file
|
69
54
|
|
70
|
-
|
71
|
-
assert_match /^.+ .+ .+ .+ before during after local$/, @output
|
72
|
-
end
|
55
|
+
assert_match(/^.+ .+ .+ .+ before during after local$/, output)
|
73
56
|
end
|
74
57
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
file
|
85
|
-
end
|
58
|
+
test "defined job with a :task and an option that is not set" do
|
59
|
+
output = Whenever.cron \
|
60
|
+
<<-file
|
61
|
+
set :job_template, nil
|
62
|
+
job_type :some_job, "before :task after :option1"
|
63
|
+
every 2.hours do
|
64
|
+
some_job "during", :option2 => 'happy'
|
65
|
+
end
|
66
|
+
file
|
86
67
|
|
87
|
-
|
88
|
-
assert_match /^.+ .+ .+ .+ before during after :option1$/, @output
|
89
|
-
end
|
68
|
+
assert_match(/^.+ .+ .+ .+ before during after :option1$/, output)
|
90
69
|
end
|
91
70
|
|
92
|
-
|
93
|
-
|
94
|
-
Whenever.stubs(:path).returns('/my/path')
|
71
|
+
test "defined job that uses a :path where none is explicitly set" do
|
72
|
+
Whenever.stubs(:path).returns('/my/path')
|
95
73
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
74
|
+
output = Whenever.cron \
|
75
|
+
<<-file
|
76
|
+
set :job_template, nil
|
77
|
+
job_type :some_job, "cd :path && :task"
|
78
|
+
every 2.hours do
|
79
|
+
some_job 'blahblah'
|
80
|
+
end
|
81
|
+
file
|
105
82
|
|
106
|
-
|
107
|
-
assert_match two_hours + %( cd /my/path && blahblah), @output
|
108
|
-
end
|
83
|
+
assert_match two_hours + %( cd /my/path && blahblah), output
|
109
84
|
end
|
110
|
-
|
111
85
|
end
|