-
-
Notifications
You must be signed in to change notification settings - Fork 278
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 an incorrect autocorrect for RSpec/PredicateMatcher
when multiline expect and predicate method with heredoc
#1555
Fix an incorrect autocorrect for RSpec/PredicateMatcher
when multiline expect and predicate method with heredoc
#1555
Conversation
eb88035
to
d51a350
Compare
d51a350
to
c5414b2
Compare
corrector_explicit(corrector, node, actual, matcher, matcher) | ||
end | ||
end | ||
end | ||
|
||
def uncorrectable_matcher?(node, matcher) | ||
str_args = matcher.arguments.select(&:str_type?) | ||
str_args.any?(&:heredoc?) && !same_line?(node, matcher) |
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.
what if the heredoc contains variables? wouldn't it be dstr_type and still contain heredoc nodes? I suggest adding dstr and xstr here
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.
Thank you for catching this. I updated this PR.
…ine expect and predicate method with heredoc This PR is fix an incorrect autocorrect for `RSpec/PredicateMatcher` when multiline expect and predicate method with heredoc. The following code: ```ruby expect(foo) .to be_something(<<~TEXT) bar TEXT ``` This would be corrected as follows: ```ruby expect(foo.something?(<<~TEXT)) .to be(true) bar TEXT ```
c5414b2
to
3799e63
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.
Thank you!
@Darhazer Is this PR ok to merge? |
…edicateMatcher Fix an incorrect autocorrect for `RSpec/PredicateMatcher` when multiline expect and predicate method with heredoc
This PR is fix an incorrect autocorrect for
RSpec/PredicateMatcher
when multiline expect and predicate method with heredoc.The following code:
This would be corrected as follows:
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).