rubocop/rubocop-rspec

`PendingWithoutReason` does not flag violations inside `shared_examples` and similar blocks

robinaugh opened this issue · 2 comments

We recently enabled PendingWithoutReason but it appears to miss usages of xcontext or xit inside certain blocks, i.e.:

RSpec.describe SomeClass do
  xcontext 'this is a violation' do
    # ...
  end

  shared_examples 'description here' do
    xcontext 'this is not a violation' do
      # ...
    end
  end

  # helper block from papertrail gem
  with_versioning do
    xit 'this is not a violation either' do
      # ...
    end
  end
end

The output of rubocop -V is below:

╰─⠠⠵ rubocop -V
1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [arm64-darwin22]
  - rubocop-capybara 2.19.0
  - rubocop-factory_bot 2.24.0
  - rubocop-rails 2.23.1
  - rubocop-rspec 2.25.0

Thanks for reporting.
Regarding shared groups, we miss a check of the parent here.

Speaking of third-party helpers, see this doc on how third-party gems can augment our RSpec DSL conf, and this doc on how to configure it for your project.

Would you like to send a PR to fix the shared example false negative?

Thanks for reporting. Regarding shared groups, we miss a check of the parent here.

Speaking of third-party helpers, see this doc on how third-party gems can augment our RSpec DSL conf, and this doc on how to configure it for your project.

Would you like to send a PR to fix the shared example false negative?

Thanks for the quick reply @pirj! I've submitted #1757 to fix the shared example false negative, and I've confirmed that this additional YML config makes that same fix work for the Papertrail gem's with_versioning helper:

RSpec:
  Language:
    SharedGroups:
      Examples:
        - with_versioning