@@ -78,6 +78,8 @@ def parse_date(str)
7878 [ "15-59/15 * * * *" , "2014-02-01 15:45" , "2014-02-01 16:15" , 4 ] ,
7979 [ "15-59/15 * * * *" , "2014-02-01 15:46" , "2014-02-01 16:15" , 3 ] ,
8080 [ "15-59/15 * * * *" , "2014-02-01 15:46" , "2014-02-01 16:15" , 2 ] ,
81+ [ "* * L 2 *" , "2015-02-01 15:36" , "2015-02-28 00:00" , 1 ] ,
82+ [ "* * L 2 *" , "2016-02-01 15:36" , "2016-02-29 00:00" , 1 ]
8183 ] . each do |line , now , expected_next , num |
8284 it "returns #{ expected_next } for '#{ line } ' when now is #{ now } " do
8385 parsed_now = parse_date ( now )
@@ -157,6 +159,8 @@ def parse_date(str)
157159 [ "15-59/15 * * * *" , "2014-02-01 15:36" , "2014-02-01 15:30" ] ,
158160 [ "15-59/15 * * * *" , "2014-02-01 15:45" , "2014-02-01 15:30" ] ,
159161 [ "15-59/15 * * * *" , "2014-02-01 15:46" , "2014-02-01 15:45" ] ,
162+ [ "* * L 2 *" , "2014-02-01 15:36" , "2013-02-28 23:59" ] ,
163+ [ "* * L 2 *" , "2017-02-01 15:36" , "2016-02-29 23:59" ]
160164 ] . each do |line , now , expected_next |
161165 it "should return #{ expected_next } for '#{ line } ' when now is #{ now } " do
162166 now = parse_date ( now )
@@ -177,6 +181,19 @@ def parse_date(str)
177181 it 'should raise error when given an invalid cronline' do
178182 expect { CronParser . new ( '* * * *' ) } . to raise_error ( 'not a valid cronline' )
179183 end
184+
185+ it 'should not raise error when L is passed in DOM field' do
186+ expect { CronParser . new ( '* * L * *' ) . next } . not_to raise_error
187+ end
188+
189+ ( 0 ..4 ) . each do |n |
190+ next if n == 2
191+ it "should raise error when L is passed in #{ n } field" do
192+ spec = Array . new ( 5 ) { '*' }
193+ spec [ n ] = 'L'
194+ expect { CronParser . new ( spec . join ( ' ' ) ) . next } . to raise_error ( "'L' specification is supported only for DOM field" )
195+ end
196+ end
180197end
181198
182199describe "time source" do
0 commit comments