Add methods to allow Timecop instance checking if in a travelled or scaled state #414
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In a recent Timecop release (0.9.7, commit c57a1fc), a fix was made to the boolean method
#frozen?
which previously returnedtrue
if Timecop was active at that instance in time (frozen, scaled or travelled). This method was changed so that only returnedtrue
if Timecop was in a frozen state. Once this change was made it was no longer possible to check if Timecop was in ascaled
ortravelled
state.As a result of this change, our automated test suite, which relied on the previous behaviour of
frozen?
failed (we used it to check if Timecop present in any way in a database helper, and it affected how our automated factory objects were being created where dates are involved). We discovered this after investigating a dependabot automated gem update failure.This PR exposes two additional methods
scaled?
andtravelled?
to allow a consumer to check for these states. I did consider an alternative methodactive?
which would have been the previousfrozen?
behaviour, but decided to be explicit in these new methods.I've added in some additional tests to cover what I think are most of the examples.
(Note: will update changelog if this PR is likely to get merged)
Thank you