RSpec/MultipleSubjects
and RSpec/LeadingSubject
autocorrect removes subject used in tests
#1835
Labels
RSpec/MultipleSubjects
and RSpec/LeadingSubject
autocorrect removes subject used in tests
#1835
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: