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

Add travel_back to remove stubs from travel and travel_to and remove auto-rollback after each test case #13884

Merged
merged 3 commits into from Jan 30, 2014

Conversation

rafaelfranca
Copy link
Member

This is a alternative implementation of #12966.

The reason is the same plus, I'm removing the auto-rollback after each test case. The reason is this auto-rollback will only work with minitest out of the box and it may confuse the users.

Closes #12966

@@ -68,8 +62,7 @@ def travel(duration, &block)
end

# Change current time to the given time by stubbing +Time.now+ and +Date.today+ to return the
# time or date passed into this method. Note that the stubs are automatically removed
# at the end of each test.
# time or date passed into this method.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to keep the doc on this method intact, as we really travelling back on the block form.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is documented below:

      # This method also accepts a block, which will return the current time back to its original
      # state at the end of the block:

What I removed is the automatically removal of the stubs in the non-block version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ha. I read it wrong. This is good to go 👍

@@ -607,6 +607,9 @@ for detailed changes.
`Time.now` and
`Date.today`. ([Pull Request](https://github.com/rails/rails/pull/12824))

* Added `ActiveSupport::Testing::TimeHelpers#travel_back`. This method return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"returns" here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@senny
Copy link
Member

senny commented Jan 30, 2014

@rafaelfranca looking good 👍

This behavior is only work out-of-box with minitest and also add a
downside to run after each test case, even if we don't used the travel
or travel_to methods
rafaelfranca added a commit that referenced this pull request Jan 30, 2014
Add `travel_back` to remove stubs from `travel` and `travel_to` and remove auto-rollback after each test case
@rafaelfranca rafaelfranca merged commit db6f69f into rails:master Jan 30, 2014
@rafaelfranca rafaelfranca deleted the rm-travel-back branch January 30, 2014 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants