rubocop / rubocop-minitest

Code style checking for Minitest files.
https://docs.rubocop.org/rubocop-minitest
MIT License
144 stars 44 forks source link

Minitest/AssertTruthy should not be enabled by default #313

Closed MatzFan closed 4 months ago

MatzFan commented 4 months ago

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

Yes. I commonly need to assert a test result is true, rather than a truthy value. The way to do this in Minitest is assert_equal true, foo.

Describe the solution you'd like

I disable this cop in every project and would simply like it disabled by default. Those that like it can enable it.

Describe alternatives you've considered

I guess I could ask @zenspider to add an assert_true and assert_false to Minitest..

Additional context

Minitest does not have an assert_true assertion, assert always passes on any truthy value. Therefore assert foo and assert_equal true, foo do different things - the latter is more specific. It was noted in #209 that this cop and RefuteFalse are not safe for autocorrect. Nagging a user who needs to test a value is exactly equal to true is not a matter of style, but of substance.

andyw8 commented 4 months ago

I suggest opening an issue in https://github.com/rubocop/minitest-style-guide to propose this.

MatzFan commented 4 months ago

Perfect, will do.