whenever 0.5.0 → 0.6.1

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,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/test_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
2
 
3
3
  class OutputRedirectionTest < Test::Unit::TestCase
4
4
 
@@ -6,6 +6,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
6
6
  setup do
7
7
  @output = Whenever.cron \
8
8
  <<-file
9
+ set :job_template, nil
9
10
  set :output, nil
10
11
  every 2.hours do
11
12
  command "blahblah"
@@ -23,6 +24,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
23
24
  setup do
24
25
  @output = Whenever.cron \
25
26
  <<-file
27
+ set :job_template, nil
26
28
  set :output, 'logfile.log'
27
29
  every 2.hours do
28
30
  command "blahblah"
@@ -39,6 +41,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
39
41
  setup do
40
42
  @output = Whenever.cron \
41
43
  <<-file
44
+ set :job_template, nil
42
45
  every 2.hours do
43
46
  command "blahblah", :output => {:standard => 'dev_null', :error => 'dev_err'}
44
47
  end
@@ -54,6 +57,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
54
57
  setup do
55
58
  @output = Whenever.cron \
56
59
  <<-file
60
+ set :job_template, nil
57
61
  set :output, 'logfile.log'
58
62
  every 2.hours do
59
63
  command "blahblah", :output => 'otherlog.log'
@@ -71,6 +75,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
71
75
  setup do
72
76
  @output = Whenever.cron \
73
77
  <<-file
78
+ set :job_template, nil
74
79
  set :output, 'logfile.log'
75
80
  every 2.hours do
76
81
  command "blahblah", :output => {:error => 'dev_err', :standard => 'dev_null' }
@@ -88,6 +93,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
88
93
  setup do
89
94
  @output = Whenever.cron \
90
95
  <<-file
96
+ set :job_template, nil
91
97
  set :output, 'logfile.log'
92
98
  every 2.hours do
93
99
  command "blahblah", :output => false
@@ -105,6 +111,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
105
111
  setup do
106
112
  @output = Whenever.cron :set => 'output=otherlog.log', :string => \
107
113
  <<-file
114
+ set :job_template, nil
108
115
  set :output, 'logfile.log'
109
116
  every 2.hours do
110
117
  command "blahblah"
@@ -122,6 +129,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
122
129
  setup do
123
130
  @output = Whenever.cron \
124
131
  <<-file
132
+ set :job_template, nil
125
133
  set :output, {:error => 'dev_err', :standard => 'dev_null' }
126
134
  every 2.hours do
127
135
  command "blahblah"
@@ -138,6 +146,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
138
146
  setup do
139
147
  @output = Whenever.cron \
140
148
  <<-file
149
+ set :job_template, nil
141
150
  set :output, {:error => 'dev_null'}
142
151
  every 2.hours do
143
152
  command "blahblah"
@@ -154,6 +163,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
154
163
  setup do
155
164
  @output = Whenever.cron \
156
165
  <<-file
166
+ set :job_template, nil
157
167
  set :output, {:standard => 'dev_out'}
158
168
  every 2.hours do
159
169
  command "blahblah"
@@ -170,6 +180,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
170
180
  setup do
171
181
  @output = Whenever.cron \
172
182
  <<-file
183
+ set :job_template, nil
173
184
  every 2.hours do
174
185
  command "blahblah", :output => {:error => 'dev_err'}
175
186
  end
@@ -185,6 +196,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
185
196
  setup do
186
197
  @output = Whenever.cron \
187
198
  <<-file
199
+ set :job_template, nil
188
200
  every 2.hours do
189
201
  command "blahblah", :output => {:standard => 'dev_out'}
190
202
  end
@@ -200,6 +212,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
200
212
  setup do
201
213
  @output = Whenever.cron \
202
214
  <<-file
215
+ set :job_template, nil
203
216
  every 2.hours do
204
217
  command "blahblah", :output => {:standard => nil}
205
218
  end
@@ -215,6 +228,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
215
228
  setup do
216
229
  @output = Whenever.cron \
217
230
  <<-file
231
+ set :job_template, nil
218
232
  every 2.hours do
219
233
  command "blahblah", :output => {:error => nil}
220
234
  end
@@ -230,6 +244,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
230
244
  setup do
231
245
  @output = Whenever.cron \
232
246
  <<-file
247
+ set :job_template, nil
233
248
  every 2.hours do
234
249
  command "blahblah", :output => {:error => nil, :standard => nil}
235
250
  end
@@ -245,6 +260,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
245
260
  setup do
246
261
  @output = Whenever.cron \
247
262
  <<-file
263
+ set :job_template, nil
248
264
  every 2.hours do
249
265
  command "blahblah", :output => {:error => nil, :standard => 'my.log'}
250
266
  end
@@ -260,6 +276,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
260
276
  setup do
261
277
  @output = Whenever.cron \
262
278
  <<-file
279
+ set :job_template, nil
263
280
  every 2.hours do
264
281
  command "blahblah", :output => {:error => 'my_error.log', :standard => nil}
265
282
  end
@@ -275,6 +292,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
275
292
  setup do
276
293
  @output = Whenever.cron \
277
294
  <<-file
295
+ set :job_template, nil
278
296
  set :cron_log, "cron.log"
279
297
  every 2.hours do
280
298
  command "blahblah"
data/test/test_helper.rb CHANGED
@@ -1,24 +1,11 @@
1
1
  require 'rubygems'
2
- require 'test/unit'
3
2
 
4
- require File.expand_path(File.dirname(__FILE__) + "/../lib/whenever")
5
-
6
- begin
7
- require 'shoulda'
8
- rescue LoadError
9
- warn 'To test Whenever you need the shoulda gem:'
10
- warn '$ sudo gem install thoughtbot-shoulda'
11
- exit(1)
12
- end
13
-
14
- begin
15
- require 'mocha'
16
- rescue LoadError
17
- warn 'To test Whenever you need the mocha gem:'
18
- warn '$ sudo gem install mocha'
19
- exit(1)
20
- end
3
+ # Want to test the files here, in lib, not in an installed version of the gem.
4
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+ require 'whenever'
21
6
 
7
+ require 'shoulda'
8
+ require 'mocha'
22
9
 
23
10
  module TestExtensions
24
11
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/test_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
2
 
3
3
  class CronTest < Test::Unit::TestCase
4
4
 
@@ -0,0 +1,77 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
+
3
+ class JobTest < Test::Unit::TestCase
4
+
5
+ context "A Job" do
6
+ should "return the :at set when #at is called" do
7
+ assert_equal 'foo', new_job(:at => 'foo').at
8
+ end
9
+
10
+ should "substitute the :task when #output is called" do
11
+ job = new_job(:template => ":task", :task => 'abc123')
12
+ assert_equal 'abc123', job.output
13
+ end
14
+
15
+ should "substitute the :path when #output is called" do
16
+ assert_equal 'foo', new_job(:template => ':path', :path => 'foo').output
17
+ end
18
+
19
+ should "substitute the :path with the default Whenever.path if none is provided when #output is called" do
20
+ Whenever.expects(:path).returns('/my/path')
21
+ assert_equal '/my/path', new_job(:template => ':path').output
22
+ end
23
+ end
24
+
25
+
26
+ context "A Job with quotes" do
27
+ should "output the :task if it's in single quotes" do
28
+ job = new_job(:template => "':task'", :task => 'abc123')
29
+ assert_equal %q('abc123'), job.output
30
+ end
31
+
32
+ should "output the :task if it's in double quotes" do
33
+ job = new_job(:template => '":task"', :task => 'abc123')
34
+ assert_equal %q("abc123"), job.output
35
+ end
36
+
37
+ should "output escaped single quotes in when it's wrapped in them" do
38
+ job = new_job(
39
+ :template => "before ':foo' after",
40
+ :foo => "quote -> ' <- quote"
41
+ )
42
+ assert_equal %q(before 'quote -> '\'' <- quote' after), job.output
43
+ end
44
+
45
+ should "output escaped double quotes when it's wrapped in them" do
46
+ job = new_job(
47
+ :template => 'before ":foo" after',
48
+ :foo => 'quote -> " <- quote'
49
+ )
50
+ assert_equal %q(before "quote -> \" <- quote" after), job.output
51
+ end
52
+ end
53
+
54
+ context "A Job with a job_template" do
55
+ should "use the job template" do
56
+ job = new_job(:template => ':task', :task => 'abc123', :job_template => 'left :job right')
57
+ assert_equal 'left abc123 right', job.output
58
+ end
59
+
60
+ should "escape single quotes" do
61
+ job = new_job(:template => "before ':task' after", :task => "quote -> ' <- quote", :job_template => "left ':job' right")
62
+ assert_equal %q(left 'before '\''quote -> '\\''\\'\\'''\\'' <- quote'\'' after' right), job.output
63
+ end
64
+
65
+ should "escape double quotes" do
66
+ job = new_job(:template => 'before ":task" after', :task => 'quote -> " <- quote', :job_template => 'left ":job" right')
67
+ assert_equal %q(left "before \"quote -> \\\" <- quote\" after" right), job.output
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def new_job(options={})
74
+ Whenever::Job.new(options)
75
+ end
76
+
77
+ end
data/whenever.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{whenever}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Javan Makhmali"]
12
- s.date = %q{2010-06-28}
13
- s.description = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
12
+ s.date = %q{2010-10-20}
13
+ s.description = %q{http://www.allyrics.net/Kid-Cudi/lyrics/Whenever/}
14
14
  s.email = %q{javan@javan.us}
15
15
  s.executables = ["whenever", "wheneverize"]
16
16
  s.extra_rdoc_files = [
@@ -25,54 +25,62 @@ Gem::Specification.new do |s|
25
25
  "bin/wheneverize",
26
26
  "lib/whenever.rb",
27
27
  "lib/whenever/base.rb",
28
+ "lib/whenever/capistrano.rb",
28
29
  "lib/whenever/command_line.rb",
30
+ "lib/whenever/cron.rb",
29
31
  "lib/whenever/job.rb",
30
32
  "lib/whenever/job_list.rb",
31
33
  "lib/whenever/job_types/default.rb",
32
- "lib/whenever/outputs/cron.rb",
33
- "lib/whenever/outputs/cron/output_redirection.rb",
34
+ "lib/whenever/output_redirection.rb",
34
35
  "lib/whenever/version.rb",
35
- "test/command_line_test.rb",
36
- "test/cron_test.rb",
37
- "test/output_at_test.rb",
38
- "test/output_command_test.rb",
39
- "test/output_defined_job_test.rb",
40
- "test/output_env_test.rb",
41
- "test/output_rake_test.rb",
42
- "test/output_redirection_test.rb",
43
- "test/output_runner_test.rb",
36
+ "test/functional/command_line_test.rb",
37
+ "test/functional/output_at_test.rb",
38
+ "test/functional/output_default_defined_jobs_test.rb",
39
+ "test/functional/output_defined_job_test.rb",
40
+ "test/functional/output_env_test.rb",
41
+ "test/functional/output_redirection_test.rb",
44
42
  "test/test_helper.rb",
43
+ "test/unit/cron_test.rb",
44
+ "test/unit/job_test.rb",
45
45
  "whenever.gemspec"
46
46
  ]
47
47
  s.homepage = %q{http://github.com/javan/whenever}
48
48
  s.rdoc_options = ["--charset=UTF-8"]
49
49
  s.require_paths = ["lib"]
50
- s.rubygems_version = %q{1.3.6}
51
- s.summary = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
50
+ s.rubygems_version = %q{1.3.7}
51
+ s.summary = %q{Clean ruby syntax for writing and deploying cron jobs.}
52
52
  s.test_files = [
53
- "test/command_line_test.rb",
54
- "test/cron_test.rb",
55
- "test/output_at_test.rb",
56
- "test/output_command_test.rb",
57
- "test/output_defined_job_test.rb",
58
- "test/output_env_test.rb",
59
- "test/output_rake_test.rb",
60
- "test/output_redirection_test.rb",
61
- "test/output_runner_test.rb",
62
- "test/test_helper.rb"
53
+ "test/functional/command_line_test.rb",
54
+ "test/functional/output_at_test.rb",
55
+ "test/functional/output_default_defined_jobs_test.rb",
56
+ "test/functional/output_defined_job_test.rb",
57
+ "test/functional/output_env_test.rb",
58
+ "test/functional/output_redirection_test.rb",
59
+ "test/test_helper.rb",
60
+ "test/unit/cron_test.rb",
61
+ "test/unit/job_test.rb"
63
62
  ]
64
63
 
65
64
  if s.respond_to? :specification_version then
66
65
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
66
  s.specification_version = 3
68
67
 
69
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
70
- s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
68
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
+ s.add_runtime_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
70
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
71
+ s.add_development_dependency(%q<shoulda>, [">= 2.1.1"])
72
+ s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
71
73
  else
72
- s.add_dependency(%q<chronic>, [">= 0.2.3"])
74
+ s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
75
+ s.add_dependency(%q<activesupport>, [">= 2.3.4"])
76
+ s.add_dependency(%q<shoulda>, [">= 2.1.1"])
77
+ s.add_dependency(%q<mocha>, [">= 0.9.5"])
73
78
  end
74
79
  else
75
- s.add_dependency(%q<chronic>, [">= 0.2.3"])
80
+ s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
81
+ s.add_dependency(%q<activesupport>, [">= 2.3.4"])
82
+ s.add_dependency(%q<shoulda>, [">= 2.1.1"])
83
+ s.add_dependency(%q<mocha>, [">= 0.9.5"])
76
84
  end
77
85
  end
78
86
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 5
8
- - 0
9
- version: 0.5.0
7
+ - 6
8
+ - 1
9
+ version: 0.6.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Javan Makhmali
@@ -14,24 +14,70 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-28 00:00:00 -04:00
17
+ date: 2010-10-20 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: chronic
21
+ name: aaronh-chronic
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
27
28
  segments:
28
29
  - 0
29
- - 2
30
30
  - 3
31
- version: 0.2.3
31
+ - 9
32
+ version: 0.3.9
32
33
  type: :runtime
33
34
  version_requirements: *id001
34
- description: Clean ruby syntax for defining and deploying messy cron jobs.
35
+ - !ruby/object:Gem::Dependency
36
+ name: activesupport
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 3
46
+ - 4
47
+ version: 2.3.4
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: shoulda
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 2
60
+ - 1
61
+ - 1
62
+ version: 2.1.1
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: mocha
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ - 9
76
+ - 5
77
+ version: 0.9.5
78
+ type: :development
79
+ version_requirements: *id004
80
+ description: http://www.allyrics.net/Kid-Cudi/lyrics/Whenever/
35
81
  email: javan@javan.us
36
82
  executables:
37
83
  - whenever
@@ -49,23 +95,23 @@ files:
49
95
  - bin/wheneverize
50
96
  - lib/whenever.rb
51
97
  - lib/whenever/base.rb
98
+ - lib/whenever/capistrano.rb
52
99
  - lib/whenever/command_line.rb
100
+ - lib/whenever/cron.rb
53
101
  - lib/whenever/job.rb
54
102
  - lib/whenever/job_list.rb
55
103
  - lib/whenever/job_types/default.rb
56
- - lib/whenever/outputs/cron.rb
57
- - lib/whenever/outputs/cron/output_redirection.rb
104
+ - lib/whenever/output_redirection.rb
58
105
  - lib/whenever/version.rb
59
- - test/command_line_test.rb
60
- - test/cron_test.rb
61
- - test/output_at_test.rb
62
- - test/output_command_test.rb
63
- - test/output_defined_job_test.rb
64
- - test/output_env_test.rb
65
- - test/output_rake_test.rb
66
- - test/output_redirection_test.rb
67
- - test/output_runner_test.rb
106
+ - test/functional/command_line_test.rb
107
+ - test/functional/output_at_test.rb
108
+ - test/functional/output_default_defined_jobs_test.rb
109
+ - test/functional/output_defined_job_test.rb
110
+ - test/functional/output_env_test.rb
111
+ - test/functional/output_redirection_test.rb
68
112
  - test/test_helper.rb
113
+ - test/unit/cron_test.rb
114
+ - test/unit/job_test.rb
69
115
  - whenever.gemspec
70
116
  has_rdoc: true
71
117
  homepage: http://github.com/javan/whenever
@@ -77,6 +123,7 @@ rdoc_options:
77
123
  require_paths:
78
124
  - lib
79
125
  required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
80
127
  requirements:
81
128
  - - ">="
82
129
  - !ruby/object:Gem::Version
@@ -84,6 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
131
  - 0
85
132
  version: "0"
86
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
+ none: false
87
135
  requirements:
88
136
  - - ">="
89
137
  - !ruby/object:Gem::Version
@@ -93,18 +141,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
141
  requirements: []
94
142
 
95
143
  rubyforge_project:
96
- rubygems_version: 1.3.6
144
+ rubygems_version: 1.3.7
97
145
  signing_key:
98
146
  specification_version: 3
99
- summary: Clean ruby syntax for defining and deploying messy cron jobs.
147
+ summary: Clean ruby syntax for writing and deploying cron jobs.
100
148
  test_files:
101
- - test/command_line_test.rb
102
- - test/cron_test.rb
103
- - test/output_at_test.rb
104
- - test/output_command_test.rb
105
- - test/output_defined_job_test.rb
106
- - test/output_env_test.rb
107
- - test/output_rake_test.rb
108
- - test/output_redirection_test.rb
109
- - test/output_runner_test.rb
149
+ - test/functional/command_line_test.rb
150
+ - test/functional/output_at_test.rb
151
+ - test/functional/output_default_defined_jobs_test.rb
152
+ - test/functional/output_defined_job_test.rb
153
+ - test/functional/output_env_test.rb
154
+ - test/functional/output_redirection_test.rb
110
155
  - test/test_helper.rb
156
+ - test/unit/cron_test.rb
157
+ - test/unit/job_test.rb
@@ -1,60 +0,0 @@
1
- module Whenever
2
- module Output
3
- class Cron
4
- class OutputRedirection
5
-
6
- def initialize(output)
7
- @output = output
8
- end
9
-
10
- def to_s
11
- return '' unless defined?(@output)
12
- case @output
13
- when String then redirect_from_string
14
- when Hash then redirect_from_hash
15
- when NilClass then ">> /dev/null 2>&1"
16
- else ''
17
- end
18
- end
19
-
20
- protected
21
-
22
- def stdout
23
- return unless @output.has_key?(:standard)
24
- @output[:standard].nil? ? '/dev/null' : @output[:standard]
25
- end
26
-
27
- def stderr
28
- return unless @output.has_key?(:error)
29
- @output[:error].nil? ? '/dev/null' : @output[:error]
30
- end
31
-
32
- def redirect_from_hash
33
- case
34
- when stdout == '/dev/null' && stderr == '/dev/null'
35
- "> /dev/null 2>&1"
36
- when stdout && stderr == '/dev/null'
37
- ">> #{stdout} 2> /dev/null"
38
- when stdout && stderr
39
- ">> #{stdout} 2>> #{stderr}"
40
- when stderr == '/dev/null'
41
- "2> /dev/null"
42
- when stderr
43
- "2>> #{stderr}"
44
- when stdout == '/dev/null'
45
- "> /dev/null"
46
- when stdout
47
- ">> #{stdout}"
48
- else
49
- ''
50
- end
51
- end
52
-
53
- def redirect_from_string
54
- ">> #{@output} 2>&1"
55
- end
56
-
57
- end
58
- end
59
- end
60
- end
@@ -1,37 +0,0 @@
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 "An every statement with two commands in it" do
21
- setup do
22
- @output = Whenever.cron \
23
- <<-file
24
- every 1.hour do
25
- command "first"
26
- command "second"
27
- end
28
- file
29
- end
30
-
31
- should "output both commands" do
32
- assert_match "0 * * * * first", @output
33
- assert_match "0 * * * * second", @output
34
- end
35
- end
36
-
37
- end
@@ -1,56 +0,0 @@
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