-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
RSpec/MultipleSubjects
and RSpec/LeadingSubject
autocorrect removes subject used in tests
#1835
Comments
Thanks for reporting. Do you think we should avoid changing the order of subject definitions and move on? |
I think that's one possible option, and is probably the right one – I feel as though we should only avoid doing it if there are multiple subjects in the context, but I don't know how practical it is to suggest that. I've also considered:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given this code:
And this reduced example command (assuming a config that requires
rubocop-rspec
):This autocorrects to:
Output:
I'm guessing the sequence of events is something like this:
RSpec/MultipleSubjects
no-ops. Ordinarily, if executed alone it would turn the namedsubject
into alet
.RSpec/LeadingSubject
moves the named subject to the start of the block.RSpec/LeadingSubject
moves the unnamed subject to the start of the block:MultipleSubjects
removes the unnamedsubject
because it will be overridden by the declaration of thenamed_subject
.This makes the test fail.
This was based on some relatively recent code (albeit a misuse of subjects). I agree with the autocorrect behaviour of
MultipleSubjects
in concept, but I'm not sure what should be done to prevent the conflict of these two cops.The text was updated successfully, but these errors were encountered: