Add Job class

This commit is contained in:
Dzmitry Plashchynski
2015-03-04 18:31:59 +02:00
parent 36c35bce7d
commit 828488a6bc
10 changed files with 91 additions and 38 deletions
+14 -7
View File
@@ -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