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

PendingWithoutReason does not flag violations inside shared_examples and similar blocks #1756

Closed
robinaugh opened this issue Dec 27, 2023 · 2 comments · Fixed by #1757
Closed

Comments

@robinaugh
Copy link
Contributor

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
@pirj
Copy link
Member

pirj commented Dec 27, 2023

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?

@robinaugh
Copy link
Contributor Author

robinaugh commented Dec 27, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants