whenever-ray 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +68 -0
- data/Manifest +24 -0
- data/README.rdoc +45 -0
- data/Rakefile +13 -0
- data/bin/whenever +32 -0
- data/bin/wheneverize +69 -0
- data/lib/base.rb +15 -0
- data/lib/command_line.rb +108 -0
- data/lib/job_list.rb +159 -0
- data/lib/job_types/default.rb +27 -0
- data/lib/job_types/rake_task.rb +12 -0
- data/lib/job_types/runner.rb +12 -0
- data/lib/outputs/cron.rb +132 -0
- data/lib/version.rb +9 -0
- data/lib/whenever.rb +36 -0
- data/test/command_line_test.rb +101 -0
- data/test/cron_test.rb +226 -0
- data/test/output_at_test.rb +178 -0
- data/test/output_command_test.rb +104 -0
- data/test/output_env_test.rb +56 -0
- data/test/output_rake_test.rb +74 -0
- data/test/output_runner_test.rb +209 -0
- data/test/test_helper.rb +33 -0
- data/whenever-ray.gemspec +34 -0
- metadata +131 -0
@@ -0,0 +1,178 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
2
|
+
|
3
|
+
class OutputAtTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "weekday at a (single) given time" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
every "weekday", :at => '5:02am' do
|
10
|
+
command "blahblah"
|
11
|
+
end
|
12
|
+
file
|
13
|
+
end
|
14
|
+
|
15
|
+
should "output the command using that time" do
|
16
|
+
assert_match '2 5 * * 1-5 blahblah', @output
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "weekday at a multiple diverse times, via an array" do
|
21
|
+
setup do
|
22
|
+
@output = Whenever.cron \
|
23
|
+
<<-file
|
24
|
+
every "weekday", :at => %w(5:02am 3:52pm) do
|
25
|
+
command "blahblah"
|
26
|
+
end
|
27
|
+
file
|
28
|
+
end
|
29
|
+
|
30
|
+
should "output the commands for both times given" do
|
31
|
+
assert_match '2 5 * * 1-5 blahblah', @output
|
32
|
+
assert_match '52 15 * * 1-5 blahblah', @output
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "weekday at a multiple diverse times, comma separated" do
|
37
|
+
setup do
|
38
|
+
@output = Whenever.cron \
|
39
|
+
<<-file
|
40
|
+
every "weekday", :at => '5:02am, 3:52pm' do
|
41
|
+
command "blahblah"
|
42
|
+
end
|
43
|
+
file
|
44
|
+
end
|
45
|
+
|
46
|
+
should "output the commands for both times given" do
|
47
|
+
assert_match '2 5 * * 1-5 blahblah', @output
|
48
|
+
assert_match '52 15 * * 1-5 blahblah', @output
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "weekday at a multiple aligned times" do
|
53
|
+
setup do
|
54
|
+
@output = Whenever.cron \
|
55
|
+
<<-file
|
56
|
+
every "weekday", :at => '5:02am, 3:02pm' do
|
57
|
+
command "blahblah"
|
58
|
+
end
|
59
|
+
file
|
60
|
+
end
|
61
|
+
|
62
|
+
should "output the command using one entry because the times are aligned" do
|
63
|
+
assert_match '2 5,15 * * 1-5 blahblah', @output
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "various days at a various aligned times" do
|
68
|
+
setup do
|
69
|
+
@output = Whenever.cron \
|
70
|
+
<<-file
|
71
|
+
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
72
|
+
command "blahblah"
|
73
|
+
end
|
74
|
+
file
|
75
|
+
end
|
76
|
+
|
77
|
+
should "output the command using one entry because the times are aligned" do
|
78
|
+
assert_match '2 5,15 * * 1,3,5 blahblah', @output
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "various days at a various aligned times using a runner" do
|
83
|
+
setup do
|
84
|
+
@output = Whenever.cron \
|
85
|
+
<<-file
|
86
|
+
set :path, '/your/path'
|
87
|
+
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
88
|
+
runner "blahblah"
|
89
|
+
end
|
90
|
+
file
|
91
|
+
end
|
92
|
+
|
93
|
+
should "output the runner using one entry because the times are aligned" do
|
94
|
+
assert_match '2 5,15 * * 1,3,5 /your/path/script/runner -e production "blahblah"', @output
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "various days at a various aligned times using a rake task" do
|
99
|
+
setup do
|
100
|
+
@output = Whenever.cron \
|
101
|
+
<<-file
|
102
|
+
set :path, '/your/path'
|
103
|
+
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
104
|
+
rake "blah:blah"
|
105
|
+
end
|
106
|
+
file
|
107
|
+
end
|
108
|
+
|
109
|
+
should "output the rake task using one entry because the times are aligned" do
|
110
|
+
assert_match '2 5,15 * * 1,3,5 cd /your/path && RAILS_ENV=production /usr/bin/env rake blah:blah', @output
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "A command every 1.month at very diverse times" do
|
115
|
+
setup do
|
116
|
+
@output = Whenever.cron \
|
117
|
+
<<-file
|
118
|
+
every [1.month, 1.day], :at => 'beginning of the month at 5:02am, june 17th at 2:22pm, june 3rd at 3:33am' do
|
119
|
+
command "blahblah"
|
120
|
+
end
|
121
|
+
file
|
122
|
+
end
|
123
|
+
|
124
|
+
should "output 6 commands since none align" do
|
125
|
+
# The 1.month commands
|
126
|
+
assert_match '2 5 1 * * blahblah', @output
|
127
|
+
assert_match '22 14 17 * * blahblah', @output
|
128
|
+
assert_match '33 3 3 * * blahblah', @output
|
129
|
+
|
130
|
+
# The 1.day commands
|
131
|
+
assert_match '2 5 * * * blahblah', @output
|
132
|
+
assert_match '22 14 * * * blahblah', @output
|
133
|
+
assert_match '33 3 * * * blahblah', @output
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "Multiple commands output every :reboot" do
|
138
|
+
setup do
|
139
|
+
@output = Whenever.cron \
|
140
|
+
<<-file
|
141
|
+
every :reboot do
|
142
|
+
command "command_1"
|
143
|
+
command "command_2"
|
144
|
+
end
|
145
|
+
file
|
146
|
+
end
|
147
|
+
|
148
|
+
should "output both commands @reboot" do
|
149
|
+
assert_match "@reboot command_1", @output
|
150
|
+
assert_match "@reboot command_2", @output
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "Many different job types output every :day" do
|
155
|
+
setup do
|
156
|
+
@output = Whenever.cron \
|
157
|
+
<<-file
|
158
|
+
set :path, '/your/path'
|
159
|
+
every :day do
|
160
|
+
rake "blah:blah"
|
161
|
+
runner "runner_1"
|
162
|
+
command "command_1"
|
163
|
+
runner "runner_2"
|
164
|
+
command "command_2"
|
165
|
+
end
|
166
|
+
file
|
167
|
+
end
|
168
|
+
|
169
|
+
should "output all of the commands @daily" do
|
170
|
+
assert_match '@daily cd /your/path && RAILS_ENV=production /usr/bin/env rake blah:blah', @output
|
171
|
+
assert_match '@daily /your/path/script/runner -e production "runner_1"', @output
|
172
|
+
assert_match '@daily command_1', @output
|
173
|
+
assert_match '@daily /your/path/script/runner -e production "runner_2"', @output
|
174
|
+
assert_match '@daily command_2', @output
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
2
|
+
|
3
|
+
class OutputCommandTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A plain command" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
every 2.hours do
|
10
|
+
command "blahblah"
|
11
|
+
end
|
12
|
+
file
|
13
|
+
end
|
14
|
+
|
15
|
+
should "output the command" do
|
16
|
+
assert_match /^.+ .+ .+ .+ blahblah$/, @output
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "A command when the cron_log is set" do
|
21
|
+
setup do
|
22
|
+
@output = Whenever.cron \
|
23
|
+
<<-file
|
24
|
+
set :cron_log, 'logfile.log'
|
25
|
+
every 2.hours do
|
26
|
+
command "blahblah"
|
27
|
+
end
|
28
|
+
file
|
29
|
+
end
|
30
|
+
|
31
|
+
should "output the command with the log syntax appended" do
|
32
|
+
assert_match /^.+ .+ .+ .+ blahblah >> logfile.log 2>&1$/, @output
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "A command when the cron_log is set and the comand overrides it" do
|
37
|
+
setup do
|
38
|
+
@output = Whenever.cron \
|
39
|
+
<<-file
|
40
|
+
set :cron_log, 'logfile.log'
|
41
|
+
every 2.hours do
|
42
|
+
command "blahblah", :cron_log => 'otherlog.log'
|
43
|
+
end
|
44
|
+
file
|
45
|
+
end
|
46
|
+
|
47
|
+
should "output the command with the log syntax appended" do
|
48
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
49
|
+
assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1$/, @output
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "A command when the cron_log is set and the comand rejects it" do
|
54
|
+
setup do
|
55
|
+
@output = Whenever.cron \
|
56
|
+
<<-file
|
57
|
+
set :cron_log, 'logfile.log'
|
58
|
+
every 2.hours do
|
59
|
+
command "blahblah", :cron_log => false
|
60
|
+
end
|
61
|
+
file
|
62
|
+
end
|
63
|
+
|
64
|
+
should "output the command without the log syntax appended" do
|
65
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
66
|
+
assert_match /^.+ .+ .+ .+ blahblah$/, @output
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "A command when the cron_log is set and is overridden by the :set option" do
|
71
|
+
setup do
|
72
|
+
@output = Whenever.cron :set => 'cron_log=otherlog.log', :string => \
|
73
|
+
<<-file
|
74
|
+
set :cron_log, 'logfile.log'
|
75
|
+
every 2.hours do
|
76
|
+
command "blahblah"
|
77
|
+
end
|
78
|
+
file
|
79
|
+
end
|
80
|
+
|
81
|
+
should "output the otherlog.log as the log file" do
|
82
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
83
|
+
assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1/, @output
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "An every statement with two commands in it" do
|
88
|
+
setup do
|
89
|
+
@output = Whenever.cron \
|
90
|
+
<<-file
|
91
|
+
every 1.hour do
|
92
|
+
command "first"
|
93
|
+
command "second"
|
94
|
+
end
|
95
|
+
file
|
96
|
+
end
|
97
|
+
|
98
|
+
should "output both commands" do
|
99
|
+
assert_match "0 * * * * first", @output
|
100
|
+
assert_match "0 * * * * second", @output
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
2
|
+
|
3
|
+
class OutputEnvTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "The output from Whenever with environment variables set" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
env :MYVAR, 'blah'
|
10
|
+
env 'MAILTO', "someone@example.com"
|
11
|
+
file
|
12
|
+
end
|
13
|
+
|
14
|
+
should "output MYVAR environment variable" do
|
15
|
+
assert_match "MYVAR=blah", @output
|
16
|
+
end
|
17
|
+
|
18
|
+
should "output MAILTO environment variable" do
|
19
|
+
assert_match "MAILTO=someone@example.com", @output
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "No PATH environment variable set" do
|
24
|
+
setup do
|
25
|
+
Whenever::JobList.any_instance.expects(:read_path).at_least_once.returns('/usr/local/bin')
|
26
|
+
@output = Whenever.cron ""
|
27
|
+
end
|
28
|
+
|
29
|
+
should "add a PATH variable based on the user's PATH" do
|
30
|
+
assert_match "PATH=/usr/local/bin", @output
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "A PATH environment variable set" do
|
35
|
+
setup do
|
36
|
+
Whenever::JobList.stubs(:read_path).returns('/usr/local/bin')
|
37
|
+
@output = Whenever.cron "env :PATH, '/my/path'"
|
38
|
+
end
|
39
|
+
|
40
|
+
should "use that path and the user's PATH" do
|
41
|
+
assert_match "PATH=/my/path", @output
|
42
|
+
assert_no_match /local/, @output
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "No PATH set and instructed not to automatically load the user's path" do
|
47
|
+
setup do
|
48
|
+
@output = Whenever.cron "set :set_path_automatically, false"
|
49
|
+
end
|
50
|
+
|
51
|
+
should "not have a PATH set" do
|
52
|
+
assert_no_match /PATH/, @output
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
2
|
+
|
3
|
+
class OutputRakeTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
# Rake are generated in an almost identical way to runners so we
|
6
|
+
# only need some basic tests to ensure they are output correctly
|
7
|
+
|
8
|
+
context "A rake command with path set" do
|
9
|
+
setup do
|
10
|
+
@output = Whenever.cron \
|
11
|
+
<<-file
|
12
|
+
set :path, '/my/path'
|
13
|
+
every 2.hours do
|
14
|
+
rake "blahblah"
|
15
|
+
end
|
16
|
+
file
|
17
|
+
end
|
18
|
+
|
19
|
+
should "output the rake command using that path" do
|
20
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production /usr/bin/env rake blahblah', @output
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "A rake command that overrides the path set" do
|
25
|
+
setup do
|
26
|
+
@output = Whenever.cron \
|
27
|
+
<<-file
|
28
|
+
set :path, '/my/path'
|
29
|
+
every 2.hours do
|
30
|
+
rake "blahblah", :path => '/some/other/path'
|
31
|
+
end
|
32
|
+
file
|
33
|
+
end
|
34
|
+
|
35
|
+
should "output the rake command using that path" do
|
36
|
+
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production /usr/bin/env rake blahblah', @output
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "A rake command with environment set" do
|
41
|
+
setup do
|
42
|
+
@output = Whenever.cron \
|
43
|
+
<<-file
|
44
|
+
set :environment, :silly
|
45
|
+
set :path, '/my/path'
|
46
|
+
every 2.hours do
|
47
|
+
rake "blahblah"
|
48
|
+
end
|
49
|
+
file
|
50
|
+
end
|
51
|
+
|
52
|
+
should "output the rake command using that environment" do
|
53
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=silly /usr/bin/env rake blahblah', @output
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "A rake command that overrides the environment set" do
|
58
|
+
setup do
|
59
|
+
@output = Whenever.cron \
|
60
|
+
<<-file
|
61
|
+
set :environment, :silly
|
62
|
+
set :path, '/my/path'
|
63
|
+
every 2.hours do
|
64
|
+
rake "blahblah", :environment => :serious
|
65
|
+
end
|
66
|
+
file
|
67
|
+
end
|
68
|
+
|
69
|
+
should "output the rake command using that environment" do
|
70
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=serious /usr/bin/env rake blahblah', @output
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
2
|
+
|
3
|
+
class OutputRunnerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A runner with path set" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
set :path, '/my/path'
|
10
|
+
every 2.hours do
|
11
|
+
runner "blahblah"
|
12
|
+
end
|
13
|
+
file
|
14
|
+
end
|
15
|
+
|
16
|
+
should "output the runner using that path" do
|
17
|
+
assert_match two_hours + ' /my/path/script/runner -e production "blahblah"', @output
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "A runner that overrides the path set" do
|
22
|
+
setup do
|
23
|
+
@output = Whenever.cron \
|
24
|
+
<<-file
|
25
|
+
set :path, '/my/path'
|
26
|
+
every 2.hours do
|
27
|
+
runner "blahblah", :path => '/some/other/path'
|
28
|
+
end
|
29
|
+
file
|
30
|
+
end
|
31
|
+
|
32
|
+
should "output the runner using that path" do
|
33
|
+
assert_match two_hours + ' /some/other/path/script/runner -e production "blahblah"', @output
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "A runner with no path set and RAILS_ROOT defined" do
|
38
|
+
setup do
|
39
|
+
Whenever.stubs(:path).returns('/my/path')
|
40
|
+
|
41
|
+
@output = Whenever.cron \
|
42
|
+
<<-file
|
43
|
+
every 2.hours do
|
44
|
+
runner "blahblah"
|
45
|
+
end
|
46
|
+
file
|
47
|
+
end
|
48
|
+
|
49
|
+
should "output the runner using that path" do
|
50
|
+
assert_match two_hours + ' /my/path/script/runner -e production "blahblah"', @output
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "A runner with path set AND RAILS_ROOT defined" do
|
55
|
+
setup do
|
56
|
+
Whenever.stubs(:path).returns('/my/rails/path')
|
57
|
+
|
58
|
+
@output = Whenever.cron \
|
59
|
+
<<-file
|
60
|
+
set :path, '/my/path'
|
61
|
+
every 2.hours do
|
62
|
+
runner "blahblah"
|
63
|
+
end
|
64
|
+
file
|
65
|
+
end
|
66
|
+
|
67
|
+
should "use the path" do
|
68
|
+
assert_match two_hours + ' /my/path/script/runner -e production "blahblah"', @output
|
69
|
+
assert_no_match /\/rails\/path/, @output
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "A runner with no path set and no RAILS_ROOT defined" do
|
74
|
+
setup do
|
75
|
+
Whenever.stubs(:path).returns(nil)
|
76
|
+
|
77
|
+
@input = <<-file
|
78
|
+
every 2.hours do
|
79
|
+
runner "blahblah"
|
80
|
+
end
|
81
|
+
file
|
82
|
+
end
|
83
|
+
|
84
|
+
should "raise an exception" do
|
85
|
+
assert_raises ArgumentError do
|
86
|
+
Whenever.cron(@input)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "A runner with an environment set" do
|
92
|
+
setup do
|
93
|
+
@output = Whenever.cron \
|
94
|
+
<<-file
|
95
|
+
set :environment, :silly
|
96
|
+
set :path, '/my/path'
|
97
|
+
every 2.hours do
|
98
|
+
runner "blahblah"
|
99
|
+
end
|
100
|
+
file
|
101
|
+
end
|
102
|
+
|
103
|
+
should "output the runner using that environment" do
|
104
|
+
assert_match two_hours + ' /my/path/script/runner -e silly "blahblah"', @output
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "A runner that overrides the environment set" do
|
109
|
+
setup do
|
110
|
+
@output = Whenever.cron \
|
111
|
+
<<-file
|
112
|
+
set :environment, :silly
|
113
|
+
set :path, '/my/path'
|
114
|
+
every 2.hours do
|
115
|
+
runner "blahblah", :environment => :serious
|
116
|
+
end
|
117
|
+
file
|
118
|
+
end
|
119
|
+
|
120
|
+
should "output the runner using that environment" do
|
121
|
+
assert_match two_hours + ' /my/path/script/runner -e serious "blahblah"', @output
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "A runner where the environment is overridden using the :set option" do
|
126
|
+
setup do
|
127
|
+
@output = Whenever.cron :set => 'environment=serious', :string => \
|
128
|
+
<<-file
|
129
|
+
set :environment, :silly
|
130
|
+
set :path, '/my/path'
|
131
|
+
every 2.hours do
|
132
|
+
runner "blahblah"
|
133
|
+
end
|
134
|
+
file
|
135
|
+
end
|
136
|
+
|
137
|
+
should "output the runner using the override environment" do
|
138
|
+
assert_match two_hours + ' /my/path/script/runner -e serious "blahblah"', @output
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "A runner where the environment and path are overridden using the :set option" do
|
143
|
+
setup do
|
144
|
+
@output = Whenever.cron :set => 'environment=serious&path=/serious/path', :string => \
|
145
|
+
<<-file
|
146
|
+
set :environment, :silly
|
147
|
+
set :path, '/silly/path'
|
148
|
+
every 2.hours do
|
149
|
+
runner "blahblah"
|
150
|
+
end
|
151
|
+
file
|
152
|
+
end
|
153
|
+
|
154
|
+
should "output the runner using the overridden path and environment" do
|
155
|
+
assert_match two_hours + ' /serious/path/script/runner -e serious "blahblah"', @output
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "A runner where the environment and path are overridden using the :set option with spaces in the string" do
|
160
|
+
setup do
|
161
|
+
@output = Whenever.cron :set => ' environment = serious& path =/serious/path', :string => \
|
162
|
+
<<-file
|
163
|
+
set :environment, :silly
|
164
|
+
set :path, '/silly/path'
|
165
|
+
every 2.hours do
|
166
|
+
runner "blahblah"
|
167
|
+
end
|
168
|
+
file
|
169
|
+
end
|
170
|
+
|
171
|
+
should "output the runner using the overridden path and environment" do
|
172
|
+
assert_match two_hours + ' /serious/path/script/runner -e serious "blahblah"', @output
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "A runner where the environment is overridden using the :set option but no value is given" do
|
177
|
+
setup do
|
178
|
+
@output = Whenever.cron :set => ' environment=', :string => \
|
179
|
+
<<-file
|
180
|
+
set :environment, :silly
|
181
|
+
set :path, '/silly/path'
|
182
|
+
every 2.hours do
|
183
|
+
runner "blahblah"
|
184
|
+
end
|
185
|
+
file
|
186
|
+
end
|
187
|
+
|
188
|
+
should "output the runner using the original environmnet" do
|
189
|
+
assert_match two_hours + ' /silly/path/script/runner -e silly "blahblah"', @output
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "A runner which makes use of double quotes" do
|
194
|
+
setup do
|
195
|
+
@output = Whenever.cron \
|
196
|
+
<<-file
|
197
|
+
set :path, '/my/path'
|
198
|
+
every 2.hours do
|
199
|
+
runner 'Product.import("http://example.com/product.xml")'
|
200
|
+
end
|
201
|
+
file
|
202
|
+
end
|
203
|
+
|
204
|
+
should "output the runner using the original environmnet" do
|
205
|
+
assert_match two_hours + ' /my/path/script/runner -e production "Product.import(\"http://example.com/product.xml\")"', @output
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|