9.x breaks this spec... why?
This is probably my fault, but this spec worked in 8.x, but in 9.x broke:
require 'spec_helper'
describe Timecop do
before(:each) do
Timecop.return
end
it 'new connections expire' do
now = Time.now
Timecop.travel(now+10)
expect(Time.now).to be >= now+10
end
end
Works fine for me; I cannot reproduce your problem.
The fact that you have this in your test:
before(:each) do
Timecop.return
end
...Makes me suspect that the real cause of your problem is something else.
You should ideally be using Timecop.travel/.freeze in block form, to ensure that the time is always reset. Or if this is too inconvenient for your use case, any such test should include Timecop.return in an after block (or some other ensure block), to ensure it always gets run.
Whilst there is nothing inherently wrong with writing Timecop.return in a before block, it makes me suspect you've patched that in as a workaround due to a leaky Timecop.travel in a different file that's not been reset.