mirror of
https://github.com/plashchynski/crono.git
synced 2026-07-19 19:21:15 +02:00
Add Job class
This commit is contained in:
+14
-7
@@ -5,16 +5,23 @@ class TestJob
|
||||
end
|
||||
|
||||
describe Crono::Schedule do
|
||||
before(:each) do
|
||||
@schedule = Crono::Schedule.new
|
||||
@jobs = [
|
||||
Crono::Period.new(3.day, at: "18:55"),
|
||||
Crono::Period.new(1.day, at: "15:30"),
|
||||
Crono::Period.new(7.day, at: "06:05")
|
||||
].map { |period| Crono::Job.new(TestJob, period) }
|
||||
@schedule.schedule = @jobs
|
||||
end
|
||||
|
||||
describe "#next" do
|
||||
it "should return next job in schedule" do
|
||||
@schedule = Crono::Schedule.new
|
||||
[
|
||||
Crono::Period.new(3.day, at: "18:55"),
|
||||
Crono::Period.new(1.day, at: "15:30"),
|
||||
Crono::Period.new(7.day, at: "06:05")
|
||||
].each { |period| @schedule.add(TestJob, period) }
|
||||
expect(@schedule.next).to be @jobs[1]
|
||||
end
|
||||
|
||||
expect(@schedule.next).to be_eql([TestJob, 1.day.from_now.change(hour: 15, min: 30)])
|
||||
it "should return next based on last" do
|
||||
expect(@schedule.next)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user