whenever 0.9.2 → 0.9.3

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,111 +1,85 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
1
+ require 'test_helper'
2
2
 
3
- class OutputDefinedJobTest < Test::Unit::TestCase
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
- context "A defined job with a :task" do
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
- context "A defined job with a :task and some options" do
23
- setup do
24
- @output = Whenever.cron \
25
- <<-file
26
- set :job_template, nil
27
- job_type :some_job, "before :task after :option1 :option2"
28
- every 2.hours do
29
- some_job "during", :option1 => 'happy', :option2 => 'birthday'
30
- end
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
- should "output the defined job with the task and options" do
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
- context "A defined job with a :task and an option where the option is set globally" do
40
- setup do
41
- @output = Whenever.cron \
42
- <<-file
43
- set :job_template, nil
44
- job_type :some_job, "before :task after :option1"
45
- set :option1, 'happy'
46
- every 2.hours do
47
- some_job "during"
48
- end
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
- should "output the defined job with the task and options" do
53
- assert_match /^.+ .+ .+ .+ before during after happy$/, @output
54
- end
41
+ assert_match /^.+ .+ .+ .+ before during after happy$/, output
55
42
  end
56
43
 
57
- context "A defined job with a :task and an option where the option is set globally and locally" do
58
- setup do
59
- @output = Whenever.cron \
60
- <<-file
61
- set :job_template, nil
62
- job_type :some_job, "before :task after :option1"
63
- set :option1, 'global'
64
- every 2.hours do
65
- some_job "during", :option1 => 'local'
66
- end
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
- should "output the defined job using the local option" do
71
- assert_match /^.+ .+ .+ .+ before during after local$/, @output
72
- end
55
+ assert_match /^.+ .+ .+ .+ before during after local$/, output
73
56
  end
74
57
 
75
- context "A defined job with a :task and an option that is not set" do
76
- setup do
77
- @output = Whenever.cron \
78
- <<-file
79
- set :job_template, nil
80
- job_type :some_job, "before :task after :option1"
81
- every 2.hours do
82
- some_job "during", :option2 => 'happy'
83
- end
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
- should "output the defined job with that option left untouched" do
88
- assert_match /^.+ .+ .+ .+ before during after :option1$/, @output
89
- end
68
+ assert_match /^.+ .+ .+ .+ before during after :option1$/, output
90
69
  end
91
70
 
92
- context "A defined job that uses a :path where none is explicitly set" do
93
- setup do
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
- @output = Whenever.cron \
97
- <<-file
98
- set :job_template, nil
99
- job_type :some_job, "cd :path && :task"
100
- every 2.hours do
101
- some_job 'blahblah'
102
- end
103
- file
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
- should "default to using the Whenever.path" do
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
@@ -1,33 +1,29 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
1
+ require 'test_helper'
2
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
- env :BLANKVAR, ''
12
- env :NILVAR, nil
13
- file
14
- end
3
+ class OutputEnvTest < Whenever::TestCase
4
+ setup do
5
+ @output = Whenever.cron \
6
+ <<-file
7
+ env :MYVAR, 'blah'
8
+ env 'MAILTO', "someone@example.com"
9
+ env :BLANKVAR, ''
10
+ env :NILVAR, nil
11
+ file
12
+ end
15
13
 
16
- should "output MYVAR environment variable" do
17
- assert_match "MYVAR=blah", @output
18
- end
19
-
20
- should "output MAILTO environment variable" do
21
- assert_match "MAILTO=someone@example.com", @output
22
- end
14
+ should "output MYVAR environment variable" do
15
+ assert_match "MYVAR=blah", @output
16
+ end
23
17
 
24
- should "output BLANKVAR environment variable" do
25
- assert_match "BLANKVAR=\"\"", @output
26
- end
18
+ should "output MAILTO environment variable" do
19
+ assert_match "MAILTO=someone@example.com", @output
20
+ end
27
21
 
28
- should "output NILVAR environment variable" do
29
- assert_match "NILVAR=\"\"", @output
30
- end
22
+ should "output BLANKVAR environment variable" do
23
+ assert_match "BLANKVAR=\"\"", @output
31
24
  end
32
25
 
26
+ should "output NILVAR environment variable" do
27
+ assert_match "NILVAR=\"\"", @output
28
+ end
33
29
  end
@@ -1,85 +1,65 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
1
+ require 'test_helper'
2
2
 
3
- class OutputJobsForRolesTest < Test::Unit::TestCase
4
- context "with one role requested and specified on the job" do
5
- setup do
6
- @output = Whenever.cron :roles => [:role1], :string => \
7
- <<-file
8
- every 2.hours, :roles => [:role1] do
9
- command "blahblah"
10
- end
11
- file
12
- end
3
+ class OutputJobsForRolesTest < Whenever::TestCase
4
+ test "one role requested and specified on the job" do
5
+ output = Whenever.cron :roles => [:role1], :string => \
6
+ <<-file
7
+ every 2.hours, :roles => [:role1] do
8
+ command "blahblah"
9
+ end
10
+ file
13
11
 
14
- should "output the cron job" do
15
- assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", @output
16
- end
12
+ assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
17
13
  end
18
14
 
19
- context "with one role requested but none specified on the job" do
20
- setup do
21
- @output = Whenever.cron :roles => [:role1], :string => \
22
- <<-file
23
- every 2.hours do
24
- command "blahblah"
25
- end
26
- file
27
- end
15
+ test "one role requested but none specified on the job" do
16
+ output = Whenever.cron :roles => [:role1], :string => \
17
+ <<-file
18
+ every 2.hours do
19
+ command "blahblah"
20
+ end
21
+ file
28
22
 
29
23
  # this should output the job because not specifying a role means "all roles"
30
- should "output the cron job" do
31
- assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", @output
32
- end
24
+ assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
33
25
  end
34
26
 
35
- context "with no roles requested but one specified on the job" do
36
- setup do
37
- @output = Whenever.cron \
38
- <<-file
39
- every 2.hours, :roles => [:role1] do
40
- command "blahblah"
41
- end
42
- file
43
- end
27
+ test "no roles requested but one specified on the job" do
28
+ output = Whenever.cron \
29
+ <<-file
30
+ every 2.hours, :roles => [:role1] do
31
+ command "blahblah"
32
+ end
33
+ file
44
34
 
45
35
  # this should output the job because not requesting roles means "all roles"
46
- should "output the cron job" do
47
- assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", @output
48
- end
36
+ assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
49
37
  end
50
38
 
51
- context "with a different role requested than the one specified on the job" do
52
- setup do
53
- @output = Whenever.cron :roles => [:role1], :string => \
54
- <<-file
55
- every 2.hours, :roles => [:role2] do
56
- command "blahblah"
57
- end
58
- file
59
- end
39
+ test "a different role requested than the one specified on the job" do
40
+ output = Whenever.cron :roles => [:role1], :string => \
41
+ <<-file
42
+ every 2.hours, :roles => [:role2] do
43
+ command "blahblah"
44
+ end
45
+ file
60
46
 
61
- should "not output the cron job" do
62
- assert_equal "", @output
63
- end
47
+ assert_equal "", output
64
48
  end
65
49
 
66
- context "with 2 roles requested and a job defined for each" do
67
- setup do
68
- @output = Whenever.cron :roles => [:role1, :role2], :string => \
69
- <<-file
70
- every 2.hours, :roles => [:role1] do
71
- command "role1_cmd"
72
- end
50
+ test "with 2 roles requested and a job defined for each" do
51
+ output = Whenever.cron :roles => [:role1, :role2], :string => \
52
+ <<-file
53
+ every 2.hours, :roles => [:role1] do
54
+ command "role1_cmd"
55
+ end
73
56
 
74
- every :hour, :roles => [:role2] do
75
- command "role2_cmd"
76
- end
77
- file
78
- end
57
+ every :hour, :roles => [:role2] do
58
+ command "role2_cmd"
59
+ end
60
+ file
79
61
 
80
- should "output both jobs" do
81
- assert_match two_hours + " /bin/bash -l -c 'role1_cmd'", @output
82
- assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", @output
83
- end
62
+ assert_match two_hours + " /bin/bash -l -c 'role1_cmd'", output
63
+ assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", output
84
64
  end
85
65
  end
@@ -1,326 +1,248 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
-
3
- class OutputRedirectionTest < Test::Unit::TestCase
4
-
5
- context "A command when the output is set to nil" do
6
- setup do
7
- @output = Whenever.cron \
8
- <<-file
9
- set :job_template, nil
10
- set :output, nil
11
- every 2.hours do
12
- command "blahblah"
13
- end
14
- file
15
- end
16
-
17
- should "output the command with the log syntax appended" do
18
- assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>&1$/, @output
19
- end
20
- end
21
-
22
-
23
- context "A command when the output is set" do
24
- setup do
25
- @output = Whenever.cron \
26
- <<-file
27
- set :job_template, nil
28
- set :output, 'logfile.log'
29
- every 2.hours do
30
- command "blahblah"
31
- end
32
- file
33
- end
34
-
35
- should "output the command with the log syntax appended" do
36
- assert_match /^.+ .+ .+ .+ blahblah >> logfile.log 2>&1$/, @output
37
- end
38
- end
39
-
40
- context "A command when the error and standard output is set by the command" do
41
- setup do
42
- @output = Whenever.cron \
43
- <<-file
44
- set :job_template, nil
45
- every 2.hours do
46
- command "blahblah", :output => {:standard => 'dev_null', :error => 'dev_err'}
47
- end
48
- file
49
- end
50
-
51
- should "output the command without the log syntax appended" do
52
- assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
53
- end
54
- end
55
-
56
- context "A command when the output is set and the comand overrides it" do
57
- setup do
58
- @output = Whenever.cron \
59
- <<-file
60
- set :job_template, nil
61
- set :output, 'logfile.log'
62
- every 2.hours do
63
- command "blahblah", :output => 'otherlog.log'
64
- end
65
- file
66
- end
67
-
68
- should "output the command with the command syntax appended" do
69
- assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
70
- assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1$/, @output
71
- end
72
- end
73
-
74
- context "A command when the output is set and the comand overrides with standard and error" do
75
- setup do
76
- @output = Whenever.cron \
77
- <<-file
78
- set :job_template, nil
79
- set :output, 'logfile.log'
80
- every 2.hours do
81
- command "blahblah", :output => {:error => 'dev_err', :standard => 'dev_null' }
82
- end
83
- file
84
- end
85
-
86
- should "output the command with the overridden redirection syntax appended" do
87
- assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
88
- assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
89
- end
90
- end
91
-
92
- context "A command when the output is set and the comand rejects it" do
93
- setup do
94
- @output = Whenever.cron \
95
- <<-file
96
- set :job_template, nil
97
- set :output, 'logfile.log'
98
- every 2.hours do
99
- command "blahblah", :output => false
100
- end
101
- file
102
- end
103
-
104
- should "output the command without the log syntax appended" do
105
- assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
106
- assert_match /^.+ .+ .+ .+ blahblah$/, @output
107
- end
108
- end
1
+ require 'test_helper'
2
+
3
+ class OutputRedirectionTest < Whenever::TestCase
4
+ test "command when the output is set to nil" do
5
+ output = Whenever.cron \
6
+ <<-file
7
+ set :job_template, nil
8
+ set :output, nil
9
+ every 2.hours do
10
+ command "blahblah"
11
+ end
12
+ file
13
+
14
+ assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>&1$/, output
15
+ end
16
+
17
+
18
+ test "command when the output is set" do
19
+ output = Whenever.cron \
20
+ <<-file
21
+ set :job_template, nil
22
+ set :output, 'logfile.log'
23
+ every 2.hours do
24
+ command "blahblah"
25
+ end
26
+ file
27
+
28
+ assert_match /^.+ .+ .+ .+ blahblah >> logfile.log 2>&1$/, output
29
+ end
30
+
31
+ test "command when the error and standard output is set by the command" do
32
+ output = Whenever.cron \
33
+ <<-file
34
+ set :job_template, nil
35
+ every 2.hours do
36
+ command "blahblah", :output => {:standard => 'dev_null', :error => 'dev_err'}
37
+ end
38
+ file
39
+
40
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output
41
+ end
42
+
43
+ test "command when the output is set and the comand overrides it" do
44
+ output = Whenever.cron \
45
+ <<-file
46
+ set :job_template, nil
47
+ set :output, 'logfile.log'
48
+ every 2.hours do
49
+ command "blahblah", :output => 'otherlog.log'
50
+ end
51
+ file
52
+
53
+ assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output
54
+ assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1$/, output
55
+ end
56
+
57
+ test "command when the output is set and the comand overrides with standard and error" do
58
+ output = Whenever.cron \
59
+ <<-file
60
+ set :job_template, nil
61
+ set :output, 'logfile.log'
62
+ every 2.hours do
63
+ command "blahblah", :output => {:error => 'dev_err', :standard => 'dev_null' }
64
+ end
65
+ file
66
+
67
+ assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output
68
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output
69
+ end
70
+
71
+ test "command when the output is set and the comand rejects it" do
72
+ output = Whenever.cron \
73
+ <<-file
74
+ set :job_template, nil
75
+ set :output, 'logfile.log'
76
+ every 2.hours do
77
+ command "blahblah", :output => false
78
+ end
79
+ file
80
+
81
+ assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output
82
+ assert_match /^.+ .+ .+ .+ blahblah$/, output
83
+ end
84
+
85
+ test "command when the output is set and is overridden by the :set option" do
86
+ output = Whenever.cron :set => 'output=otherlog.log', :string => \
87
+ <<-file
88
+ set :job_template, nil
89
+ set :output, 'logfile.log'
90
+ every 2.hours do
91
+ command "blahblah"
92
+ end
93
+ file
94
+
95
+ assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output
96
+ assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1/, output
97
+ end
98
+
99
+ test "command when the error and standard output is set" do
100
+ output = Whenever.cron \
101
+ <<-file
102
+ set :job_template, nil
103
+ set :output, {:error => 'dev_err', :standard => 'dev_null' }
104
+ every 2.hours do
105
+ command "blahblah"
106
+ end
107
+ file
108
+
109
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output
110
+ end
111
+
112
+ test "command when error output is set" do
113
+ output = Whenever.cron \
114
+ <<-file
115
+ set :job_template, nil
116
+ set :output, {:error => 'dev_null'}
117
+ every 2.hours do
118
+ command "blahblah"
119
+ end
120
+ file
121
+
122
+ assert_match /^.+ .+ .+ .+ blahblah 2>> dev_null$/, output
123
+ end
124
+
125
+ test "command when the standard output is set" do
126
+ output = Whenever.cron \
127
+ <<-file
128
+ set :job_template, nil
129
+ set :output, {:standard => 'dev_out'}
130
+ every 2.hours do
131
+ command "blahblah"
132
+ end
133
+ file
134
+
135
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_out$/, output
136
+ end
137
+
138
+ test "command when error output is set by the command" do
139
+ output = Whenever.cron \
140
+ <<-file
141
+ set :job_template, nil
142
+ every 2.hours do
143
+ command "blahblah", :output => {:error => 'dev_err'}
144
+ end
145
+ file
146
+
147
+ assert_match /^.+ .+ .+ .+ blahblah 2>> dev_err$/, output
148
+ end
149
+
150
+ test "command when standard output is set by the command" do
151
+ output = Whenever.cron \
152
+ <<-file
153
+ set :job_template, nil
154
+ every 2.hours do
155
+ command "blahblah", :output => {:standard => 'dev_out'}
156
+ end
157
+ file
158
+
159
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_out$/, output
160
+ end
161
+
162
+ test "command when standard output is set to nil" do
163
+ output = Whenever.cron \
164
+ <<-file
165
+ set :job_template, nil
166
+ every 2.hours do
167
+ command "blahblah", :output => {:standard => nil}
168
+ end
169
+ file
170
+
171
+ assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null$/, output
172
+ end
173
+
174
+ test "command when standard error is set to nil" do
175
+ output = Whenever.cron \
176
+ <<-file
177
+ set :job_template, nil
178
+ every 2.hours do
179
+ command "blahblah", :output => {:error => nil}
180
+ end
181
+ file
109
182
 
110
- context "A command when the output is set and is overridden by the :set option" do
111
- setup do
112
- @output = Whenever.cron :set => 'output=otherlog.log', :string => \
113
- <<-file
114
- set :job_template, nil
115
- set :output, 'logfile.log'
116
- every 2.hours do
117
- command "blahblah"
118
- end
119
- file
120
- end
121
-
122
- should "output the otherlog.log as the log file" do
123
- assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
124
- assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1/, @output
125
- end
126
- end
127
-
128
- context "A command when the error and standard output is set" do
129
- setup do
130
- @output = Whenever.cron \
131
- <<-file
132
- set :job_template, nil
133
- set :output, {:error => 'dev_err', :standard => 'dev_null' }
134
- every 2.hours do
135
- command "blahblah"
136
- end
137
- file
138
- end
139
-
140
- should "output the command without the redirection syntax appended" do
141
- assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
142
- end
143
- end
144
-
145
- context "A command when error output is set" do
146
- setup do
147
- @output = Whenever.cron \
148
- <<-file
149
- set :job_template, nil
150
- set :output, {:error => 'dev_null'}
151
- every 2.hours do
152
- command "blahblah"
153
- end
154
- file
155
- end
156
-
157
- should "output the command without the standard error syntax appended" do
158
- assert_match /^.+ .+ .+ .+ blahblah 2>> dev_null$/, @output
159
- end
160
- end
161
-
162
- context "A command when the standard output is set" do
163
- setup do
164
- @output = Whenever.cron \
165
- <<-file
166
- set :job_template, nil
167
- set :output, {:standard => 'dev_out'}
168
- every 2.hours do
169
- command "blahblah"
170
- end
171
- file
172
- end
173
-
174
- should "output the command with standard output syntax appended" do
175
- assert_match /^.+ .+ .+ .+ blahblah >> dev_out$/, @output
176
- end
177
- end
183
+ assert_match /^.+ .+ .+ .+ blahblah 2> \/dev\/null$/, output
184
+ end
185
+
186
+ test "command when standard output and standard error is set to nil" do
187
+ output = Whenever.cron \
188
+ <<-file
189
+ set :job_template, nil
190
+ every 2.hours do
191
+ command "blahblah", :output => {:error => nil, :standard => nil}
192
+ end
193
+ file
178
194
 
179
- context "A command when error output is set by the command" do
180
- setup do
181
- @output = Whenever.cron \
182
- <<-file
183
- set :job_template, nil
184
- every 2.hours do
185
- command "blahblah", :output => {:error => 'dev_err'}
186
- end
187
- file
188
- end
189
-
190
- should "output the command without the log syntax appended" do
191
- assert_match /^.+ .+ .+ .+ blahblah 2>> dev_err$/, @output
192
- end
195
+ assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, output
193
196
  end
194
197
 
195
- context "A command when standard output is set by the command" do
196
- setup do
197
- @output = Whenever.cron \
198
- <<-file
199
- set :job_template, nil
200
- every 2.hours do
201
- command "blahblah", :output => {:standard => 'dev_out'}
202
- end
203
- file
204
- end
205
-
206
- should "output the command without the log syntax appended" do
207
- assert_match /^.+ .+ .+ .+ blahblah >> dev_out$/, @output
208
- end
209
- end
198
+ test "command when standard output is set and standard error is set to nil" do
199
+ output = Whenever.cron \
200
+ <<-file
201
+ set :job_template, nil
202
+ every 2.hours do
203
+ command "blahblah", :output => {:error => nil, :standard => 'my.log'}
204
+ end
205
+ file
210
206
 
211
- context "A command when standard output is set to nil" do
212
- setup do
213
- @output = Whenever.cron \
214
- <<-file
215
- set :job_template, nil
216
- every 2.hours do
217
- command "blahblah", :output => {:standard => nil}
218
- end
219
- file
220
- end
221
-
222
- should "output the command with stdout directed to /dev/null" do
223
- assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null$/, @output
224
- end
207
+ assert_match /^.+ .+ .+ .+ blahblah >> my.log 2> \/dev\/null$/, output
225
208
  end
226
209
 
227
- context "A command when standard error is set to nil" do
228
- setup do
229
- @output = Whenever.cron \
230
- <<-file
231
- set :job_template, nil
232
- every 2.hours do
233
- command "blahblah", :output => {:error => nil}
234
- end
235
- file
236
- end
237
-
238
- should "output the command with stderr directed to /dev/null" do
239
- assert_match /^.+ .+ .+ .+ blahblah 2> \/dev\/null$/, @output
240
- end
241
- end
210
+ test "command when standard output is nil and standard error is set" do
211
+ output = Whenever.cron \
212
+ <<-file
213
+ set :job_template, nil
214
+ every 2.hours do
215
+ command "blahblah", :output => {:error => 'my_error.log', :standard => nil}
216
+ end
217
+ file
242
218
 
243
- context "A command when standard output and standard error is set to nil" do
244
- setup do
245
- @output = Whenever.cron \
246
- <<-file
247
- set :job_template, nil
248
- every 2.hours do
249
- command "blahblah", :output => {:error => nil, :standard => nil}
250
- end
251
- file
252
- end
253
-
254
- should "output the command with stderr directed to /dev/null" do
255
- assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, @output
256
- end
219
+ assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, output
257
220
  end
258
221
 
259
- context "A command when standard output is set and standard error is set to nil" do
260
- setup do
261
- @output = Whenever.cron \
262
- <<-file
263
- set :job_template, nil
264
- every 2.hours do
265
- command "blahblah", :output => {:error => nil, :standard => 'my.log'}
266
- end
267
- file
268
- end
269
-
270
- should "output the command with stderr directed to /dev/null" do
271
- assert_match /^.+ .+ .+ .+ blahblah >> my.log 2> \/dev\/null$/, @output
272
- end
273
- end
222
+ test "command when the deprecated :cron_log is set" do
223
+ output = Whenever.cron \
224
+ <<-file
225
+ set :job_template, nil
226
+ set :cron_log, "cron.log"
227
+ every 2.hours do
228
+ command "blahblah"
229
+ end
230
+ file
274
231
 
275
- context "A command when standard output is nil and standard error is set" do
276
- setup do
277
- @output = Whenever.cron \
278
- <<-file
279
- set :job_template, nil
280
- every 2.hours do
281
- command "blahblah", :output => {:error => 'my_error.log', :standard => nil}
282
- end
283
- file
284
- end
285
-
286
- should "output the command with stderr directed to /dev/null" do
287
- assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, @output
288
- end
232
+ assert_match /^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, output
289
233
  end
290
234
 
291
- context "A command when the deprecated :cron_log is set" do
292
- setup do
293
- @output = Whenever.cron \
294
- <<-file
295
- set :job_template, nil
296
- set :cron_log, "cron.log"
297
- every 2.hours do
298
- command "blahblah"
299
- end
300
- file
301
- end
302
-
303
- should "output the command with with the stdout and stderr going to the log" do
304
- assert_match /^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, @output
305
- end
306
- end
307
235
 
236
+ test "a command when the standard output is set to a lambda" do
237
+ output = Whenever.cron \
238
+ <<-file
239
+ set :job_template, nil
240
+ set :output, lambda { "2>&1 | logger -t whenever_cron" }
241
+ every 2.hours do
242
+ command "blahblah"
243
+ end
244
+ file
308
245
 
309
- context "A command when the standard output is set to a lambda" do
310
- setup do
311
- @output = Whenever.cron \
312
- <<-file
313
- set :job_template, nil
314
- set :output, lambda { "2>&1 | logger -t whenever_cron" }
315
- every 2.hours do
316
- command "blahblah"
317
- end
318
- file
319
- end
320
-
321
- should "output the command by result of the lambda evaluated" do
322
- assert_match /^.+ .+ .+ .+ blahblah 2>&1 | logger -t whenever_cron$/, @output
323
- end
246
+ assert_match /^.+ .+ .+ .+ blahblah 2>&1 | logger -t whenever_cron$/, output
324
247
  end
325
-
326
248
  end