mirror of
https://github.com/plashchynski/crono.git
synced 2026-04-21 00:11:34 +02:00
Period#next should return today time if it is first run and not too late
This commit is contained in:
@@ -22,12 +22,14 @@ describe Crono::Period do
|
||||
end
|
||||
|
||||
it "should set time to 'at' time as a string" do
|
||||
@period = Crono::Period.new(2.day, at: "15:20")
|
||||
expect(@period.next).to be_eql(2.day.from_now.change(hour: 15, min: 20))
|
||||
time = 10.minutes.ago
|
||||
@period = Crono::Period.new(2.day, at: [time.hour, time.min].join(':'))
|
||||
expect(@period.next).to be_eql(2.day.from_now.change(hour: time.hour, min: time.min))
|
||||
end
|
||||
|
||||
it "should set time to 'at' time as a hash" do
|
||||
at = {hour: 18, min: 45}
|
||||
time = 10.minutes.ago
|
||||
at = {hour: time.hour, min: time.min}
|
||||
@period = Crono::Period.new(2.day, at: at)
|
||||
expect(@period.next).to be_eql(2.day.from_now.change(at))
|
||||
end
|
||||
@@ -42,6 +44,13 @@ describe Crono::Period do
|
||||
@period = Crono::Period.new(2.day)
|
||||
expect(@period.next(since: 1.day.ago)).to be_eql(1.day.from_now)
|
||||
end
|
||||
|
||||
it "should return today time if it is first run and not too late" do
|
||||
time = 10.minutes.from_now
|
||||
at = {hour: time.hour, min: time.min}
|
||||
@period = Crono::Period.new(2.day, at: at)
|
||||
expect(@period.next).to be_eql(Time.now.change(at))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,11 +25,7 @@ describe Crono::Scheduler do
|
||||
|
||||
describe "#next" do
|
||||
it "should return next job in schedule" do
|
||||
expect(@scheduler.next).to be @jobs[1]
|
||||
end
|
||||
|
||||
it "should return next based on last" do
|
||||
expect(@scheduler.next)
|
||||
expect(@scheduler.next).to be @jobs[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user