Skip to content

RSpec/EmptyLineAfterFinalLet not triggered inside it_behaves_like block #2040

Open
@Darhazer

Description

@Darhazer

I just noticed that RSpec/EmptyLineAfterFinalLet is not being triggered when the offending code is inside a it_behaves_like block. It might be affecting other cops as well.

Failing test

it 'registers an offense for empty line after last let in shared examples' do
    expect_offense(<<~RUBY)
      RSpec.describe User do
        it_behaves_like 'some shared behaviour' do
          let(:a) { a }
          let(:b) { b }
          ^^^^^^^^^^^^^ Add an empty line after the last `let`.
          it { expect(a).to eq(b) }
        end
      end
    RUBY
end

Potentially it_behaves_like blocks should be considered examples groups


Expected behavior

The code above is flagged it it is inside a context, but it_behaves_like block creates context

Actual behavior

The code above to be flagged and corrected

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions