spec/job_cron_spec.rb in rufus-scheduler-3.0.9 vs spec/job_cron_spec.rb in rufus-scheduler-3.1.0
- old
+ new
@@ -100,7 +100,29 @@
expect(first - n).to be < 4.0
break
end
end
end
+
+ describe '.next_time' do
+
+ it 'returns the next trigger time' do
+
+ n = Time.now
+ nt = Time.parse("#{n.year}-#{n.month + 1}-01")
+
+ expect(
+ @scheduler.schedule_cron('* * 1 * *', lambda {}).next_time
+ ).to eq(nt)
+ end
+
+ it 'returns the next trigger time (first_at => Time)' do
+
+ ft = Time.parse('2100-12-31')
+
+ job = @scheduler.schedule_cron('* * 1 * *', :first_at => ft) {}
+
+ expect(job.next_time).to eq(ft)
+ end
+ end
end