timecop
timecop copied to clipboard
Allow unblocked freeze/travel when already in a freeze block?
If Timecop is already frozen within a block, shouldn't future unblocked freeze
and travel
calls be considered "safe"?
Here's an example of where I would find this construct useful:
it "is a shame" do
Timecop.safe_mode = true
expect(Object).to receive(:bar) { Timecop.freeze(Time.now.utc + 10) }
Timecop.freeze do
old_time = Time.now.utc
Object.bar
expect(old_time).to eq Time.now.utc - 10
end
end
+1
I have some specs that freeze time using a block, then travel:
it 'tests timey wimey stuff' do
Timecop.freeze do
assert_time_based_stuff
Timecop.travel 1.day.from_now
assert_more_time_based_stuff
end
end
This currently blows up when in safe mode, but I feel like it shouldn't.
+1
Tired of having ridiculous nestings as a result.