Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when an error is raised in a Timecop.return block #126



Copy link

@camertron camertron commented Sep 11, 2014

Consider this example: - (1 * 24 * 60 * 60)) do
  Timecop.return { puts; raise 'foo!' } rescue nil

Console output:

2014-09-10 14:05:55 -0700
2014-09-11 14:05:55 -0700
2014-09-11 14:05:55 -0700

Errors raised in a Timecop.return block mean the previous time is never restored, undoing any freezes or travels. This PR simply adds an ensure statement in Timecop#return that ensures the current stack always gets restored, even when an error occurs in the yield.

…ch unsets any global freezes or travels
Copy link
Contributor Author

@camertron camertron commented Oct 3, 2014

Any idea when this might be merged, @travisjeffery?

Copy link

@travisjeffery travisjeffery commented Feb 19, 2015

Ah, nice! Thank you!

travisjeffery pushed a commit that referenced this pull request Feb 19, 2015
Issue when an error is raised in a Timecop.return block
@travisjeffery travisjeffery merged commit 8093f4a into travisjeffery:master Feb 19, 2015
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.