freeze time in spec

This commit is contained in:
Sam 2017-07-24 13:00:15 -04:00
parent 40abcfc2f5
commit 7ebb9874a8
1 changed files with 4 additions and 2 deletions

View File

@ -58,13 +58,15 @@ describe Scheduler::ScheduleInfo do
class DailyJob
extend ::Scheduler::Schedule
daily at: 2.hours
daily at: 11.hours
def perform
end
end
before do
freeze_time Time.parse("2010-01-10 10:00:00")
@info = manager.schedule_info(DailyJob)
@info.del!
end
@ -87,7 +89,7 @@ describe Scheduler::ScheduleInfo do
@info.schedule!
expect(JSON.parse($redis.get(@info.key))["next_run"])
.to eq((Time.zone.now.midnight + 2.hours).to_i)
.to eq((Time.now.midnight + 11.hours).to_i)
expect(@info.valid?).to eq(true)
end