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
Fix infinite correction loop in RSpec/ExampleWording #1438
Conversation
9fa60c9
to
8bb9c1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a test for explicitly being expect_no_corrections?
Also, it seems like it would be a better to mention in the documentation the cases that are not autocorrected. How about it?
else | ||
check_and_handle_insufficient_examples(description_node) | ||
elsif insufficient_docstring?(description_node) | ||
add_offense(docstring(description_node), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding next if text(node) == replacement_text(node)
in the auto-correction?
RuboCop thinks correction was made because the autocorrect didn't return nil
, even though the correction resulted in replacing with the same value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a bit hacky, for two reasons.
For "should do something" we know we have a correction, but we'll be making this check that will also return false
.
For "works" we know we don't have a correction, so the check will be true
.
I'm shortcutting (in a good way) here to skip autocorrection for "works", along with this check.
@ydah This expectation was passing before the fix - no surprise, it was replacing "works" with "works". But I deliberately decided not to add this expectation because it's deceiving, at least not in the scope of this PR. Don't trust a spec you didn't see fail™ |
Indeed it is. Thank you. |
Fix infinite correction loop in RSpec/ExampleWording
fixes #1433
Since we don't have any corrections for an insufficient example wording like "works", we keep "replacing" the description with itself.
NOTE:
expect_no_corrections
was passing. But RuboCop was (falsely?) detecting that a change has been made, and was re-running the cop over and over.Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).