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

Add Minitest/AssertEqualClass cop #242

Closed
wants to merge 1 commit into from

Conversation

sambostock
Copy link
Contributor

This cop enforces the test to use assert_instance_of instead of using assert_equal(Class, object.class).

# bad
assert_equal(Class, object.class)
assert_equal(Class, object.class, 'message')

# good
assert_instance_of(Class, object)
assert_instance_of(Class, object, 'message')

Arguably, this could be part of the Minitest/AssertInstanceOf cop, but that cop is metaprogramed, so would have to be reimplemented.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

This cop enforces the test to use `assert_instance_of` instead of using
`assert_equal(Class, object.class)`.

Arguably, this could be part of the `Minitest/AssertInstanceOf` cop, but
that cop is metaprogramed, so would have to be reimplemented.
@koic
Copy link
Member

koic commented Feb 15, 2023

Arguably, this could be part of the Minitest/AssertInstanceOf cop, but that cop is metaprogramed, so would have to be reimplemented.

Yeah. It would be better to extend instead of metaprogramming for Minitest/AssertInstanceOf.

@koic
Copy link
Member

koic commented Feb 21, 2023

@sambostock Can you reimplement Minitest/AssertInstanceOf instead of creating Minitest/AssertEqualClass? Minitest/AssertInstanceOf could be updated to an implementation that doesn't use MinitestCopRule and define_rule.

@koic
Copy link
Member

koic commented Mar 20, 2023

@sambostock Will you continue to take this?

@koic
Copy link
Member

koic commented Mar 28, 2023

I'm going to close this PR because this feature request will be resolved in #248. Thank you.

@koic koic closed this Mar 28, 2023
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.

None yet

2 participants