spec/every_spec.rb in rufus-scheduler-2.0.8 vs spec/every_spec.rb in rufus-scheduler-2.0.9

- old
+ new

@@ -93,25 +93,49 @@ it 'honours :first_at' do counter = 0 - job = @s.every '1s', :first_at => Time.now + 2 do + @s.every '1s', :first_at => Time.now + 2 do counter += 1 end sleep 1 counter.should == 0 sleep 2.5 counter.should == 2 end + it 'triggers for the missed schedules when :first_at is in the past' do + + counter = 0 + + @s.every '1s', :first_at => Time.now - 2 do + counter += 1 + end + + wait_next_tick + counter.should == 3 + end + + it 'does not trigger for the missed schedules when :first_at is in the past and :discard_past => true' do + + counter = 0 + + @s.every '1s', :first_at => Time.now - 2, :discard_past => true do + counter += 1 + end + + wait_next_tick + counter.should == 0 + end + it 'honours :first_in' do counter = 0 - job = @s.every '1s', :first_in => 2 do + @s.every '1s', :first_in => 2 do counter += 1 end sleep 1 counter.should == 0