-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Rails/RedundantTravelBack should not auto-correct #579
Comments
Well, I tried to fix this by doing the following:
Tests are still failing after removing the travel_back |
pieforproviders/pieforproviders#1904 - Draft PR so you can see the changes |
@katelovescode I ran specs (
On your screenshot, I see some unrelated specs (spec/requests/api) are failing, is it the same on the integration branch? Or is it a lead? You both use transactional specs ( In any case, failures seem unrelated to the behaviour of What do you think? |
I think a lot of your comments make sense, thanks for taking the time to look into this and to run the tests locally. I agree with you, my test-suite alone should not dictate that this is unsafe for autocorrection 😂 Those unrelated specs that were failing also only failed when I removed the travel_backs so I'm not really sure. They pass on all the other branches right now. As for the transactional specs and DB cleaner - I'm not sure honestly, I think I may have run into a bug during testing and found the transactional fixtures as a possible fix, and then maybe didn't ever clear it out. I'm working on a big refactor that will necessitate a lot of spec changes so hopefully I can start digging some of this mess out. Thanks again for your time, I'll close this issue as not necessary. |
I've turned off Rails/RedundantTravelBack because it's auto-corrected and on by default, but the
after_teardown
hook is only called in Minitest, not in RSpec, from what I can tell. So my travel_backs are getting removed even though I use Rspec and need them. Given that we can initialize Rails without Minitest, does it make sense to make this clearer in documentation and/or not autocorrect this particular cop? It seems like this behavior, even though it's built into part of Rails, is more Minitest-specific.Since this lives at the intersection of Rails and RSpec, I'm not sure if there's a better rubocop extension to add this to, happy to open a PR at
rubocop-rspec
if that makes more sense.Expected behavior
Not remove my necessary travel_back calls
Actual behavior
Necessary travel_back calls are removed
Steps to reproduce the problem
In a Rails app using RSpec instead of minitest, put an
after { travel_back }
hook in a file wheretravel_to
happens in a before block or in an expectation block. Runrubocop -a
and your travel_back will be removed, and your tests will breakRuboCop version
The text was updated successfully, but these errors were encountered: