manual/cops_minitest.md in rubocop-minitest-0.3.0 vs manual/cops_minitest.md in rubocop-minitest-0.4.0

- old
+ new

@@ -23,10 +23,33 @@ ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-empty](https://github.com/rubocop-hq/minitest-style-guide#assert-empty) +## Minitest/AssertEqual + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.4 | - + +This cop enforces the use of `assert_equal(expected, actual)` +over `assert(expected == actual)`. + +### Examples + +```ruby +# bad +assert("rubocop-minitest" == actual) + +# good +assert_equal("rubocop-minitest", actual) +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#assert-equal-arguments-order](https://github.com/rubocop-hq/minitest-style-guide#assert-equal-arguments-order) + ## Minitest/AssertIncludes Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.2 | - @@ -48,10 +71,35 @@ ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-includes](https://github.com/rubocop-hq/minitest-style-guide#assert-includes) +## Minitest/AssertInstanceOf + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.4 | - + +This cop enforces the test to use `assert_instance_of(Class, object)` +over `assert(object.instance_of?(Class))`. + +### Examples + +```ruby +# bad +assert(object.instance_of?(Class)) +assert(object.instance_of?(Class), 'the message') + +# good +assert_instance_of(Class, object) +assert_instance_of(Class, object, 'the message') +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of](https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of) + ## Minitest/AssertNil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.1 | - @@ -155,11 +203,11 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.3 | - This cop enforces the use of `refute_equal(expected, object)` -over `assert_equal(expected != actual)` or `assert(! expected -= actual)`. +over `assert_equal(expected != actual)` or `assert(! expected == actual)`. ### Examples ```ruby # bad @@ -222,10 +270,35 @@ ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-includes](https://github.com/rubocop-hq/minitest-style-guide#refute-includes) +## Minitest/RefuteInstanceOf + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.4 | - + +This cop enforces the use of `refute_instance_of(Class, object)` +over `refute(object.instance_of?(Class))`. + +### Examples + +```ruby +# bad +refute(object.instance_of?(Class)) +refute(object.instance_of?(Class), 'the message') + +# good +refute_instance_of(Class, object) +refute_instance_of(Class, object, 'the message') +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of](https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of) + ## Minitest/RefuteNil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.2 | - @@ -246,5 +319,30 @@ ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-nil](https://github.com/rubocop-hq/minitest-style-guide#refute-nil) + +## Minitest/RefuteRespondTo + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.4 | - + +This cop enforces the test to use `refute_respond_to(object, :some_method)` +over `refute(object.respond_to?(:some_method))`. + +### Examples + +```ruby +# bad +refute(object.respond_to?(:some_method)) +refute(object.respond_to?(:some_method), 'the message') + +# good +refute_respond_to(object, :some_method) +refute_respond_to(object, :some_method, 'the message') +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to](https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to)