whenever 0.4.1 → 0.5.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.
- data/.gitignore +2 -1
- data/CHANGELOG.rdoc +31 -0
- data/README.rdoc +24 -12
- data/Rakefile +9 -6
- data/bin/whenever +8 -3
- data/lib/whenever/base.rb +1 -5
- data/lib/whenever/command_line.rb +22 -6
- data/lib/whenever/{outputs/cron.rb → cron.rb} +3 -5
- data/lib/whenever/job.rb +41 -0
- data/lib/whenever/job_list.rb +24 -24
- data/lib/whenever/job_types/default.rb +3 -27
- data/lib/whenever/{outputs/cron/output_redirection.rb → output_redirection.rb} +9 -3
- data/lib/whenever/version.rb +1 -1
- data/lib/whenever.rb +4 -25
- data/test/functional/command_line_test.rb +288 -0
- data/test/{output_at_test.rb → functional/output_at_test.rb} +63 -4
- data/test/{output_rake_test.rb → functional/output_default_defined_jobs_test.rb} +37 -21
- data/test/functional/output_defined_job_test.rb +105 -0
- data/test/{output_env_test.rb → functional/output_env_test.rb} +1 -1
- data/test/{output_redirection_test.rb → functional/output_redirection_test.rb} +11 -11
- data/test/test_helper.rb +5 -18
- data/test/{cron_test.rb → unit/cron_test.rb} +1 -1
- data/test/unit/job_test.rb +69 -0
- data/whenever.gemspec +35 -27
- metadata +82 -30
- data/lib/whenever/job_types/rake_task.rb +0 -12
- data/lib/whenever/job_types/runner.rb +0 -12
- data/test/command_line_test.rb +0 -101
- data/test/output_command_test.rb +0 -37
- data/test/output_runner_test.rb +0 -209
data/test/test_helper.rb
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
-
require 'test/unit'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
|
@@ -0,0 +1,69 @@
|
|
|
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 "return :output when #output_redirection is called" do
|
|
11
|
+
assert_equal 'foo', new_job(:output => 'foo').output_redirection
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "return :not_set when #output_redirection is called and no :output is set" do
|
|
15
|
+
assert_equal :not_set, new_job.output_redirection
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "substitute the :task when #output is called" do
|
|
19
|
+
job = new_job(:template => ":task", :task => 'abc123')
|
|
20
|
+
assert_equal 'abc123', job.output
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should "substitute the :path when #output is called" do
|
|
24
|
+
assert_equal 'foo', new_job(:template => ':path', :path => 'foo').output
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
should "substitute the :path with the default Whenever.path if none is provided when #output is called" do
|
|
28
|
+
Whenever.expects(:path).returns('/my/path')
|
|
29
|
+
assert_equal '/my/path', new_job(:template => ':path').output
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
context "A Job with quotes" do
|
|
35
|
+
|
|
36
|
+
should "output the :task if it's in single quotes" do
|
|
37
|
+
job = new_job(:template => "':task'", :task => 'abc123')
|
|
38
|
+
assert_equal %q('abc123'), job.output
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
should "output the :task if it's in double quotes" do
|
|
42
|
+
job = new_job(:template => '":task"', :task => 'abc123')
|
|
43
|
+
assert_equal %q("abc123"), job.output
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
should "output escaped single quotes in when it's wrapped in them" do
|
|
47
|
+
job = new_job(
|
|
48
|
+
:template => "before ':foo' after",
|
|
49
|
+
:foo => "quote -> ' <- quote"
|
|
50
|
+
)
|
|
51
|
+
assert_equal %q(before 'quote -> '\'' <- quote' after), job.output
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should "output escaped double quotes when it's wrapped in them" do
|
|
55
|
+
job = new_job(
|
|
56
|
+
:template => 'before ":foo" after',
|
|
57
|
+
:foo => 'quote -> " <- quote'
|
|
58
|
+
)
|
|
59
|
+
assert_equal %q(before "quote -> \" <- quote" after), job.output
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def new_job(options={})
|
|
66
|
+
Whenever::Job.new(options)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
data/whenever.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{whenever}
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.5.2"
|
|
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{
|
|
12
|
+
s.date = %q{2010-09-15}
|
|
13
13
|
s.description = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
|
|
14
14
|
s.email = %q{javan@javan.us}
|
|
15
15
|
s.executables = ["whenever", "wheneverize"]
|
|
@@ -26,39 +26,38 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
"lib/whenever.rb",
|
|
27
27
|
"lib/whenever/base.rb",
|
|
28
28
|
"lib/whenever/command_line.rb",
|
|
29
|
+
"lib/whenever/cron.rb",
|
|
30
|
+
"lib/whenever/job.rb",
|
|
29
31
|
"lib/whenever/job_list.rb",
|
|
30
32
|
"lib/whenever/job_types/default.rb",
|
|
31
|
-
"lib/whenever/
|
|
32
|
-
"lib/whenever/job_types/runner.rb",
|
|
33
|
-
"lib/whenever/outputs/cron.rb",
|
|
34
|
-
"lib/whenever/outputs/cron/output_redirection.rb",
|
|
33
|
+
"lib/whenever/output_redirection.rb",
|
|
35
34
|
"lib/whenever/version.rb",
|
|
36
|
-
"test/command_line_test.rb",
|
|
37
|
-
"test/
|
|
38
|
-
"test/
|
|
39
|
-
"test/
|
|
40
|
-
"test/output_env_test.rb",
|
|
41
|
-
"test/
|
|
42
|
-
"test/output_redirection_test.rb",
|
|
43
|
-
"test/output_runner_test.rb",
|
|
35
|
+
"test/functional/command_line_test.rb",
|
|
36
|
+
"test/functional/output_at_test.rb",
|
|
37
|
+
"test/functional/output_default_defined_jobs_test.rb",
|
|
38
|
+
"test/functional/output_defined_job_test.rb",
|
|
39
|
+
"test/functional/output_env_test.rb",
|
|
40
|
+
"test/functional/output_redirection_test.rb",
|
|
44
41
|
"test/test_helper.rb",
|
|
42
|
+
"test/unit/cron_test.rb",
|
|
43
|
+
"test/unit/job_test.rb",
|
|
45
44
|
"whenever.gemspec"
|
|
46
45
|
]
|
|
47
46
|
s.homepage = %q{http://github.com/javan/whenever}
|
|
48
47
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
49
48
|
s.require_paths = ["lib"]
|
|
50
|
-
s.rubygems_version = %q{1.3.
|
|
49
|
+
s.rubygems_version = %q{1.3.6}
|
|
51
50
|
s.summary = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
|
|
52
51
|
s.test_files = [
|
|
53
|
-
"test/command_line_test.rb",
|
|
54
|
-
"test/
|
|
55
|
-
"test/
|
|
56
|
-
"test/
|
|
57
|
-
"test/output_env_test.rb",
|
|
58
|
-
"test/
|
|
59
|
-
"test/
|
|
60
|
-
"test/
|
|
61
|
-
"test/
|
|
52
|
+
"test/functional/command_line_test.rb",
|
|
53
|
+
"test/functional/output_at_test.rb",
|
|
54
|
+
"test/functional/output_default_defined_jobs_test.rb",
|
|
55
|
+
"test/functional/output_defined_job_test.rb",
|
|
56
|
+
"test/functional/output_env_test.rb",
|
|
57
|
+
"test/functional/output_redirection_test.rb",
|
|
58
|
+
"test/test_helper.rb",
|
|
59
|
+
"test/unit/cron_test.rb",
|
|
60
|
+
"test/unit/job_test.rb"
|
|
62
61
|
]
|
|
63
62
|
|
|
64
63
|
if s.respond_to? :specification_version then
|
|
@@ -66,12 +65,21 @@ Gem::Specification.new do |s|
|
|
|
66
65
|
s.specification_version = 3
|
|
67
66
|
|
|
68
67
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
69
|
-
s.add_runtime_dependency(%q<chronic>, [">= 0.
|
|
68
|
+
s.add_runtime_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
|
69
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
|
|
70
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.1.1"])
|
|
71
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
|
|
70
72
|
else
|
|
71
|
-
s.add_dependency(%q<chronic>, [">= 0.
|
|
73
|
+
s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
|
74
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.4"])
|
|
75
|
+
s.add_dependency(%q<shoulda>, [">= 2.1.1"])
|
|
76
|
+
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
|
72
77
|
end
|
|
73
78
|
else
|
|
74
|
-
s.add_dependency(%q<chronic>, [">= 0.
|
|
79
|
+
s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
|
80
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.4"])
|
|
81
|
+
s.add_dependency(%q<shoulda>, [">= 2.1.1"])
|
|
82
|
+
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
|
75
83
|
end
|
|
76
84
|
end
|
|
77
85
|
|
metadata
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: whenever
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 5
|
|
8
|
+
- 2
|
|
9
|
+
version: 0.5.2
|
|
5
10
|
platform: ruby
|
|
6
11
|
authors:
|
|
7
12
|
- Javan Makhmali
|
|
@@ -9,19 +14,65 @@ autorequire:
|
|
|
9
14
|
bindir: bin
|
|
10
15
|
cert_chain: []
|
|
11
16
|
|
|
12
|
-
date:
|
|
17
|
+
date: 2010-09-15 00:00:00 -04:00
|
|
13
18
|
default_executable:
|
|
14
19
|
dependencies:
|
|
15
20
|
- !ruby/object:Gem::Dependency
|
|
16
|
-
name: chronic
|
|
21
|
+
name: aaronh-chronic
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
segments:
|
|
28
|
+
- 0
|
|
29
|
+
- 3
|
|
30
|
+
- 9
|
|
31
|
+
version: 0.3.9
|
|
17
32
|
type: :runtime
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
version_requirements: *id001
|
|
34
|
+
- !ruby/object:Gem::Dependency
|
|
35
|
+
name: activesupport
|
|
36
|
+
prerelease: false
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
segments:
|
|
42
|
+
- 2
|
|
43
|
+
- 3
|
|
44
|
+
- 4
|
|
45
|
+
version: 2.3.4
|
|
46
|
+
type: :runtime
|
|
47
|
+
version_requirements: *id002
|
|
48
|
+
- !ruby/object:Gem::Dependency
|
|
49
|
+
name: shoulda
|
|
50
|
+
prerelease: false
|
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
segments:
|
|
56
|
+
- 2
|
|
57
|
+
- 1
|
|
58
|
+
- 1
|
|
59
|
+
version: 2.1.1
|
|
60
|
+
type: :development
|
|
61
|
+
version_requirements: *id003
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: mocha
|
|
64
|
+
prerelease: false
|
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
20
66
|
requirements:
|
|
21
67
|
- - ">="
|
|
22
68
|
- !ruby/object:Gem::Version
|
|
23
|
-
|
|
24
|
-
|
|
69
|
+
segments:
|
|
70
|
+
- 0
|
|
71
|
+
- 9
|
|
72
|
+
- 5
|
|
73
|
+
version: 0.9.5
|
|
74
|
+
type: :development
|
|
75
|
+
version_requirements: *id004
|
|
25
76
|
description: Clean ruby syntax for defining and deploying messy cron jobs.
|
|
26
77
|
email: javan@javan.us
|
|
27
78
|
executables:
|
|
@@ -41,22 +92,21 @@ files:
|
|
|
41
92
|
- lib/whenever.rb
|
|
42
93
|
- lib/whenever/base.rb
|
|
43
94
|
- lib/whenever/command_line.rb
|
|
95
|
+
- lib/whenever/cron.rb
|
|
96
|
+
- lib/whenever/job.rb
|
|
44
97
|
- lib/whenever/job_list.rb
|
|
45
98
|
- lib/whenever/job_types/default.rb
|
|
46
|
-
- lib/whenever/
|
|
47
|
-
- lib/whenever/job_types/runner.rb
|
|
48
|
-
- lib/whenever/outputs/cron.rb
|
|
49
|
-
- lib/whenever/outputs/cron/output_redirection.rb
|
|
99
|
+
- lib/whenever/output_redirection.rb
|
|
50
100
|
- lib/whenever/version.rb
|
|
51
|
-
- test/command_line_test.rb
|
|
52
|
-
- test/
|
|
53
|
-
- test/
|
|
54
|
-
- test/
|
|
55
|
-
- test/output_env_test.rb
|
|
56
|
-
- test/
|
|
57
|
-
- test/output_redirection_test.rb
|
|
58
|
-
- test/output_runner_test.rb
|
|
101
|
+
- test/functional/command_line_test.rb
|
|
102
|
+
- test/functional/output_at_test.rb
|
|
103
|
+
- test/functional/output_default_defined_jobs_test.rb
|
|
104
|
+
- test/functional/output_defined_job_test.rb
|
|
105
|
+
- test/functional/output_env_test.rb
|
|
106
|
+
- test/functional/output_redirection_test.rb
|
|
59
107
|
- test/test_helper.rb
|
|
108
|
+
- test/unit/cron_test.rb
|
|
109
|
+
- test/unit/job_test.rb
|
|
60
110
|
- whenever.gemspec
|
|
61
111
|
has_rdoc: true
|
|
62
112
|
homepage: http://github.com/javan/whenever
|
|
@@ -71,28 +121,30 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
71
121
|
requirements:
|
|
72
122
|
- - ">="
|
|
73
123
|
- !ruby/object:Gem::Version
|
|
124
|
+
segments:
|
|
125
|
+
- 0
|
|
74
126
|
version: "0"
|
|
75
|
-
version:
|
|
76
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
128
|
requirements:
|
|
78
129
|
- - ">="
|
|
79
130
|
- !ruby/object:Gem::Version
|
|
131
|
+
segments:
|
|
132
|
+
- 0
|
|
80
133
|
version: "0"
|
|
81
|
-
version:
|
|
82
134
|
requirements: []
|
|
83
135
|
|
|
84
136
|
rubyforge_project:
|
|
85
|
-
rubygems_version: 1.3.
|
|
137
|
+
rubygems_version: 1.3.6
|
|
86
138
|
signing_key:
|
|
87
139
|
specification_version: 3
|
|
88
140
|
summary: Clean ruby syntax for defining and deploying messy cron jobs.
|
|
89
141
|
test_files:
|
|
90
|
-
- test/command_line_test.rb
|
|
91
|
-
- test/
|
|
92
|
-
- test/
|
|
93
|
-
- test/
|
|
94
|
-
- test/output_env_test.rb
|
|
95
|
-
- test/
|
|
96
|
-
- test/output_redirection_test.rb
|
|
97
|
-
- test/output_runner_test.rb
|
|
142
|
+
- test/functional/command_line_test.rb
|
|
143
|
+
- test/functional/output_at_test.rb
|
|
144
|
+
- test/functional/output_default_defined_jobs_test.rb
|
|
145
|
+
- test/functional/output_defined_job_test.rb
|
|
146
|
+
- test/functional/output_env_test.rb
|
|
147
|
+
- test/functional/output_redirection_test.rb
|
|
98
148
|
- test/test_helper.rb
|
|
149
|
+
- test/unit/cron_test.rb
|
|
150
|
+
- test/unit/job_test.rb
|
data/test/command_line_test.rb
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
-
|
|
3
|
-
class CommandLineTest < Test::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
context "A command line write" do
|
|
6
|
-
setup do
|
|
7
|
-
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
|
8
|
-
@command = Whenever::CommandLine.new(:write => true, :identifier => 'My identifier')
|
|
9
|
-
@task = "#{two_hours} /my/command"
|
|
10
|
-
Whenever.expects(:cron).returns(@task)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
should "output the cron job with identifier blocks" do
|
|
14
|
-
output = <<-EXPECTED
|
|
15
|
-
# Begin Whenever generated tasks for: My identifier
|
|
16
|
-
#{@task}
|
|
17
|
-
# End Whenever generated tasks for: My identifier
|
|
18
|
-
EXPECTED
|
|
19
|
-
|
|
20
|
-
assert_equal output, @command.send(:whenever_cron)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
should "write the crontab when run" do
|
|
24
|
-
@command.expects(:write_crontab).returns(true)
|
|
25
|
-
assert @command.run
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
context "A command line update" do
|
|
30
|
-
setup do
|
|
31
|
-
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
|
32
|
-
@command = Whenever::CommandLine.new(:update => true, :identifier => 'My identifier')
|
|
33
|
-
@task = "#{two_hours} /my/command"
|
|
34
|
-
Whenever.expects(:cron).returns(@task)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
should "add the cron to the end of the file if there is no existing identifier block" do
|
|
38
|
-
existing = '# Existing crontab'
|
|
39
|
-
@command.expects(:read_crontab).at_least_once.returns(existing)
|
|
40
|
-
|
|
41
|
-
new_cron = <<-EXPECTED
|
|
42
|
-
#{existing}
|
|
43
|
-
|
|
44
|
-
# Begin Whenever generated tasks for: My identifier
|
|
45
|
-
#{@task}
|
|
46
|
-
# End Whenever generated tasks for: My identifier
|
|
47
|
-
EXPECTED
|
|
48
|
-
|
|
49
|
-
assert_equal new_cron, @command.send(:updated_crontab)
|
|
50
|
-
|
|
51
|
-
@command.expects(:write_crontab).with(new_cron).returns(true)
|
|
52
|
-
assert @command.run
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
should "replace an existing block if the identifier matches" do
|
|
56
|
-
existing = <<-EXISTING_CRON
|
|
57
|
-
# Something
|
|
58
|
-
|
|
59
|
-
# Begin Whenever generated tasks for: My identifier
|
|
60
|
-
My whenever job that was already here
|
|
61
|
-
# End Whenever generated tasks for: My identifier
|
|
62
|
-
|
|
63
|
-
# Begin Whenever generated tasks for: Other identifier
|
|
64
|
-
This shouldn't get replaced
|
|
65
|
-
# End Whenever generated tasks for: Other identifier
|
|
66
|
-
EXISTING_CRON
|
|
67
|
-
|
|
68
|
-
@command.expects(:read_crontab).at_least_once.returns(existing)
|
|
69
|
-
|
|
70
|
-
new_cron = <<-NEW_CRON
|
|
71
|
-
# Something
|
|
72
|
-
|
|
73
|
-
# Begin Whenever generated tasks for: My identifier
|
|
74
|
-
#{@task}
|
|
75
|
-
# End Whenever generated tasks for: My identifier
|
|
76
|
-
|
|
77
|
-
# Begin Whenever generated tasks for: Other identifier
|
|
78
|
-
This shouldn't get replaced
|
|
79
|
-
# End Whenever generated tasks for: Other identifier
|
|
80
|
-
NEW_CRON
|
|
81
|
-
|
|
82
|
-
assert_equal new_cron, @command.send(:updated_crontab)
|
|
83
|
-
|
|
84
|
-
@command.expects(:write_crontab).with(new_cron).returns(true)
|
|
85
|
-
assert @command.run
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
context "A command line update with no identifier" do
|
|
90
|
-
setup do
|
|
91
|
-
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
|
92
|
-
Whenever::CommandLine.any_instance.expects(:default_identifier).returns('DEFAULT')
|
|
93
|
-
@command = Whenever::CommandLine.new(:update => true, :file => @file)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
should "use the default identifier" do
|
|
97
|
-
assert_equal "Whenever generated tasks for: DEFAULT", @command.send(:comment_base)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
end
|
data/test/output_command_test.rb
DELETED
|
@@ -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
|