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

feat: support *_instance_of in RSpec/Rails/MinitestAssertions #1780

Merged
merged 2 commits into from
Jan 14, 2024

Conversation

G-Rath
Copy link
Contributor

@G-Rath G-Rath commented Jan 13, 2024

Related to rubocop/rubocop-rspec_rails#7

I've not included this in the cops documentation as I figure ultimately documenting every single form of matcher translation could end up being pretty big and this is a straightforward one - happy to add it though if folks disagree/don't mind the length.

I've also refactored the assertion classes so they extend from a basic parent that handles the generation of the actual matchers - I've kept this as a separate commit for easier review and in case folks want that landed in a different PR (or not at all).


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.

@G-Rath G-Rath requested a review from a team as a code owner January 13, 2024 19:41
end

def assertion
"be_an_instance_of(#{@expected})"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with this form since it's the grammatically correct version and the "original" (be_instance_of is an alias)

Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Nice refactoring and addition! Thank you

Copy link
Member

@ydah ydah left a comment

Choose a reason for hiding this comment

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

Thank you!

@ydah ydah merged commit 288061b into rubocop:master Jan 14, 2024
24 checks passed
@G-Rath G-Rath deleted the support-assert-instance-of branch January 14, 2024 18:02
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.

3 participants