Skip to content

Conversation

@gildesmarais
Copy link

Adds autocorrect support for RSpec/MultipleExpectations cop, handling hash or :symbol example metadata.

Rake fails due to apparently unrelated changes
rspec ./spec/rubocop/cop/rspec/mixin/top_level_group_spec.rb:19 # RuboCop::Cop::RSpec::TopLevelGroup#top_level_group? warns because it is deprecated
rspec ./spec/rubocop/cop/rspec/nested_groups_spec.rb:122 # RuboCop::Cop::RSpec::NestedGroups when configured with MaxNesting emits a deprecation warning

If that's related to the changes, I'd appreciate a pointer where to fix them. Thank you. :)


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

If you have created a new cop:

  • Added the new cop to config/default.yml.
  • The cop is configured as Enabled: pending in config/default.yml.
  • The cop is configured as Enabled: true in .rubocop.yml.
  • The cop documents examples of good and bad code.
  • The tests assert both that bad code is reported and that good code is not reported.
  • Set VersionAdded: "<<next>>" in default/config.yml.

If you have modified an existing cop's configuration options:

  • Set VersionChanged: "<<next>>" in config/default.yml.

@gildesmarais gildesmarais marked this pull request as ready for review December 5, 2025 17:11
@gildesmarais gildesmarais requested a review from a team as a code owner December 5, 2025 17:11
Copy link
Collaborator

@bquorning bquorning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gildesmarais and thank you for the PR; sorry it took us a while to respond.

I am not sure about why you get those two warnings/errors locally, and I am also not sure how to replicate it.

It looks like you need to add a couple more tests to get 100% coverage. (The coverage results can be seen locally in coverage/index.html after running rspec).

Also please run rake generate_cops_documentation and add docs/ to the commit.

if node.arguments.empty?
# Handle cases like `it { ... }` vs `it(...) { ... }`
loc, str = if node.loc.begin
[node.loc.begin, ':aggregate_failures']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add test coverage for this line, please?

Comment on lines +188 to +189
corrector.insert_before(hash_node.loc.end,
' aggregate_failures: true ')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add test coverage for this line too, please?

def_node_matcher :aggregate_failures?, <<~PATTERN
(send _ _ <{ (sym :aggregate_failures) (hash <(pair (sym :aggregate_failures) _) ...>) } ...>)
PATTERN
# @!method metadata_present?(node)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# @!method metadata_present?(node)
# @!method metadata_present?(node)

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 this pull request may close these issues.

2 participants