@@ -77,6 +77,8 @@ def parse_date(str)
77
77
[ "15-59/15 * * * *" , "2014-02-01 15:45" , "2014-02-01 16:15" , 4 ] ,
78
78
[ "15-59/15 * * * *" , "2014-02-01 15:46" , "2014-02-01 16:15" , 3 ] ,
79
79
[ "15-59/15 * * * *" , "2014-02-01 15:46" , "2014-02-01 16:15" , 2 ] ,
80
+ [ "* * L 2 *" , "2015-02-01 15:36" , "2015-02-28 00:00" , 1 ] ,
81
+ [ "* * L 2 *" , "2016-02-01 15:36" , "2016-02-29 00:00" , 1 ]
80
82
] . each do |line , now , expected_next , num |
81
83
it "returns #{ expected_next } for '#{ line } ' when now is #{ now } " do
82
84
parsed_now = parse_date ( now )
@@ -156,6 +158,8 @@ def parse_date(str)
156
158
[ "15-59/15 * * * *" , "2014-02-01 15:36" , "2014-02-01 15:30" ] ,
157
159
[ "15-59/15 * * * *" , "2014-02-01 15:45" , "2014-02-01 15:30" ] ,
158
160
[ "15-59/15 * * * *" , "2014-02-01 15:46" , "2014-02-01 15:45" ] ,
161
+ [ "* * L 2 *" , "2014-02-01 15:36" , "2013-02-28 23:59" ] ,
162
+ [ "* * L 2 *" , "2017-02-01 15:36" , "2016-02-29 23:59" ]
159
163
] . each do |line , now , expected_next |
160
164
it "should return #{ expected_next } for '#{ line } ' when now is #{ now } " do
161
165
now = parse_date ( now )
@@ -176,6 +180,19 @@ def parse_date(str)
176
180
it 'should raise error when given an invalid cronline' do
177
181
expect { CronParser . new ( '* * * *' ) } . to raise_error ( 'not a valid cronline' )
178
182
end
183
+
184
+ it 'should not raise error when L is passed in DOM field' do
185
+ expect { CronParser . new ( '* * L * *' ) . next } . not_to raise_error
186
+ end
187
+
188
+ ( 0 ..4 ) . each do |n |
189
+ next if n == 2
190
+ it "should raise error when L is passed in #{ n } field" do
191
+ spec = Array . new ( 5 ) { '*' }
192
+ spec [ n ] = 'L'
193
+ expect { CronParser . new ( spec . join ( ' ' ) ) . next } . to raise_error ( "'L' specification is supported only for DOM field" )
194
+ end
195
+ end
179
196
end
180
197
181
198
RSpec . describe "time source" do
0 commit comments