On my rspec I call the rails helper method freeze_time
before do
freeze_time
end
Do I need to run something to unfreeze Time after the specs
after do
#unfreeze time
end
CodePudding user response:
yes, you have to. Normally I use this with a block so that I don't impact other test example in case i forgot the unfreeze. This is quite common when the spec file is kinda big.
it 'testing freeze time' do
freeze_time do
# do some stuff
end
# time is no longer freeze from now on
end
CodePudding user response:
You need to use travel_back
to go back to original time like this.
after do
travel_back
end
Here is the documentation of travel_back
.