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

Make Minitest/AssertPredicate aware of assert_not_predicate #1155

Open
Earlopain opened this issue Oct 13, 2023 · 1 comment · May be fixed by #1259
Open

Make Minitest/AssertPredicate aware of assert_not_predicate #1155

Earlopain opened this issue Oct 13, 2023 · 1 comment · May be fixed by #1259

Comments

@Earlopain
Copy link
Contributor

Earlopain commented Oct 13, 2023

Is your feature request related to a problem? Please describe.

Currently Minitest/AssertPredicate corrects assert(foo.bar?) to assert_predicate(foo, :bar?).
It would be nice if the same is also true for the negation of this. assert_not(foo.bar?) to assert_not_predicate(foo, :bar?).

I have openend this issue here instead of the minitest gem because assert_not_predicate and assert_not are rails specific methods.

@Earlopain
Copy link
Contributor Author

@koic could you give me some pointers on how you would approach this? I'm not sure where I would start when implementing.

Would it make sense to:

  • Make Minitest/AssertPredicate aware of this by default
  • Add a config to Minitest/AssertPredicate that would be default enhanced here if the gem is present (are there other cops here that do this I could look take a look at?)
  • Something else entirely?

Earlopain added a commit to Earlopain/rubocop-rails that referenced this issue Mar 22, 2024
This converts `assert_not(obj.one?)` into `assert_not_predicate(obj, :one?)`
These methods are rails-specific and not present by default in minitest.

For users that prefer the `refute` method calls, `Rails/RefuteMethods` will correct this if configured that way.

Both the code and tests are pretty much a one-to-one copy from rubocop-minitest.`RefutePredicate`
@Earlopain Earlopain linked a pull request Mar 22, 2024 that will close this issue
9 tasks
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.

1 participant