From 7ebb9874a8ed677cba11c44540862ec45e96d69f Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Jul 2017 13:00:15 -0400 Subject: [PATCH] freeze time in spec --- spec/components/scheduler/schedule_info_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/components/scheduler/schedule_info_spec.rb b/spec/components/scheduler/schedule_info_spec.rb index 719dc8482e6..419f9383582 100644 --- a/spec/components/scheduler/schedule_info_spec.rb +++ b/spec/components/scheduler/schedule_info_spec.rb @@ -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