whenever 0.5.0 → 0.6.2

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.
@@ -1,74 +0,0 @@
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
@@ -1,175 +0,0 @@
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 + ' cd /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 + ' cd /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 + ' cd /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 + ' cd /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 an environment set" do
74
- setup do
75
- @output = Whenever.cron \
76
- <<-file
77
- set :environment, :silly
78
- set :path, '/my/path'
79
- every 2.hours do
80
- runner "blahblah"
81
- end
82
- file
83
- end
84
-
85
- should "output the runner using that environment" do
86
- assert_match two_hours + ' cd /my/path && script/runner -e silly "blahblah"', @output
87
- end
88
- end
89
-
90
- context "A runner that overrides the environment set" do
91
- setup do
92
- @output = Whenever.cron \
93
- <<-file
94
- set :environment, :silly
95
- set :path, '/my/path'
96
- every 2.hours do
97
- runner "blahblah", :environment => :serious
98
- end
99
- file
100
- end
101
-
102
- should "output the runner using that environment" do
103
- assert_match two_hours + ' cd /my/path && script/runner -e serious "blahblah"', @output
104
- end
105
- end
106
-
107
- context "A runner where the environment is overridden using the :set option" do
108
- setup do
109
- @output = Whenever.cron :set => 'environment=serious', :string => \
110
- <<-file
111
- set :environment, :silly
112
- set :path, '/my/path'
113
- every 2.hours do
114
- runner "blahblah"
115
- end
116
- file
117
- end
118
-
119
- should "output the runner using the override environment" do
120
- assert_match two_hours + ' cd /my/path && script/runner -e serious "blahblah"', @output
121
- end
122
- end
123
-
124
- context "A runner where the environment and path are overridden using the :set option" do
125
- setup do
126
- @output = Whenever.cron :set => 'environment=serious&path=/serious/path', :string => \
127
- <<-file
128
- set :environment, :silly
129
- set :path, '/silly/path'
130
- every 2.hours do
131
- runner "blahblah"
132
- end
133
- file
134
- end
135
-
136
- should "output the runner using the overridden path and environment" do
137
- assert_match two_hours + ' cd /serious/path && script/runner -e serious "blahblah"', @output
138
- end
139
- end
140
-
141
- context "A runner where the environment and path are overridden using the :set option with spaces in the string" do
142
- setup do
143
- @output = Whenever.cron :set => ' environment = serious& path =/serious/path', :string => \
144
- <<-file
145
- set :environment, :silly
146
- set :path, '/silly/path'
147
- every 2.hours do
148
- runner "blahblah"
149
- end
150
- file
151
- end
152
-
153
- should "output the runner using the overridden path and environment" do
154
- assert_match two_hours + ' cd /serious/path && script/runner -e serious "blahblah"', @output
155
- end
156
- end
157
-
158
- context "A runner where the environment is overridden using the :set option but no value is given" do
159
- setup do
160
- @output = Whenever.cron :set => ' environment=', :string => \
161
- <<-file
162
- set :environment, :silly
163
- set :path, '/silly/path'
164
- every 2.hours do
165
- runner "blahblah"
166
- end
167
- file
168
- end
169
-
170
- should "output the runner using the original environmnet" do
171
- assert_match two_hours + ' cd /silly/path && script/runner -e silly "blahblah"', @output
172
- end
173
- end
174
-
175
- end