Skip to content
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 subject nesting detection in RSpec/LeadingSubject #1011

Merged
merged 1 commit into from Aug 21, 2020

Commits on Aug 21, 2020

  1. Fix subject nesting detection in RSpec/LeadingSubject

    For the following code:
    
        RSpec.describe User do
          let(:foo) { 'bar' }
          it_behaves_like 'a good citizen' do
            subject { described_class.new }
          end
        end
    
    when `on_block` is triggered for `subject`,
    `node.parent.each_child_node.to_a` is:
    
        [
          s(:send, nil, :it_behaves_like, s(:str, "a good citizen")),
          s(:args),
          s(:block, s(:send, nil, :subject), s(:args), s(:send, s(:send, nil, :described_class), :new))
        ]
    
    and autocorrect was putting the subject block above all "offenders"
    coming before it, including the `it_behaves_like` send node.
    pirj committed Aug 21, 2020
    Copy the full SHA
    fefb978 View commit details
    Browse the repository at this point in the history