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/LeadingSubject
is crashing if subject[]
is used inside let
#1150
Comments
I can't reproduce this with an example group: RSpec.describe 'A' do
subject { { foo: 1 } }
let(:bar) { subject[:foo] }
it { foo }
end Do you use |
The code above is the whole reproducer, found the crash when playing with |
Sorry, RuboCop RSpec is not supposed to work on source files that are not valid RSpec files. |
I can provide valid spec then :) def example_setup
subject { { foo: 1 } }
let(:bar) { subject[:foo] }
end
RSpec.describe Mail do
instance_exec(&method(:example_setup))
specify do
p subject
p bar
end
end Anyway, while IMHO all the crashes should be handled, I understand if this one will be WONTIX though. |
We make assumptions that RSpec DSL elements are properly structured, and Do you suggest we made explicit checks to all the cops that the RSpec DSL is in order, and skip checking those files? RSpec DSL configuration feature (#956) has been released not long ago, to tell RuboCop RSpec about project-specific custom example group aliases. I believe if we start skipping those blocks that are actually example groups, but just are not configured as such in In any case, a pull request is welcome if you have an idea how to elegantly fix such a case with no side effects. |
leads to
The text was updated successfully, but these errors were encountered: