freeze time for the whole suite so all the Time.now calls sprinkled through the old tests won't error if there is a delay on Travis CI

This commit is contained in:
Renée Hendricksen 2016-07-12 19:23:24 -04:00
parent c10145cc93
commit 16968f445f
2 changed files with 11 additions and 0 deletions

View File

@ -62,3 +62,12 @@ RSpec.configure do |c|
end
end
end
require 'timecop'
Timecop.freeze(Time.now.utc)
describe Time do
let(:time) { Time.now.utc }
example { expect(Time.now.utc).to eq(time) }
example { expect(Time.now.utc + 5.minutes ).to eq(time + 5.minutes) }
end

View File

@ -7,11 +7,13 @@ describe Travis::API::V3::Models::Cron do
describe "next build time is calculated correctly on year changes" do
before do
Timecop.return
Timecop.travel(DateTime.new(2015, 12, 31, 16))
end
after do
Timecop.return
Timecop.freeze(Time.now.utc)
end
it "for daily builds" do