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

- old
+ new

@@ -4,22 +4,23 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.2 | - -Check if your test uses `assert_empty` instead of `assert(actual.empty?)`. +This cop enforces the test to use `assert_empty` +instead of using `assert(object.empty?)`. ### Examples ```ruby # bad -assert(actual.empty?) -assert(actual.empty?, 'the message') +assert(object.empty?) +assert(object.empty?, 'the message') # good -assert_empty(actual) -assert_empty(actual, 'the message') +assert_empty(object) +assert_empty(object, 'the message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-empty](https://github.com/rubocop-hq/minitest-style-guide#assert-empty) @@ -28,23 +29,23 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.2 | - -Check if your test uses `assert_includes` -instead of `assert(collection.includes?(actual))`. +This cop enforces the test to use `assert_includes` +instead of using `assert(collection.include?(object))`. ### Examples ```ruby # bad -assert(collection.includes?(actual)) -assert(collection.includes?(actual), 'the message') +assert(collection.include?(object)) +assert(collection.include?(object), 'the message') # good -assert_includes(collection, actual) -assert_includes(collection, actual, 'the message') +assert_includes(collection, object) +assert_includes(collection, object, 'the message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-includes](https://github.com/rubocop-hq/minitest-style-guide#assert-includes) @@ -53,11 +54,12 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.1 | - -Check if your test uses `assert_nil` instead of `assert_equal(nil, something)`. +This cop enforces the test to use `assert_nil` +instead of using `assert_equal(nil, something)`. ### Examples ```ruby # bad @@ -71,18 +73,43 @@ ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-nil](https://github.com/rubocop-hq/minitest-style-guide#assert-nil) +## Minitest/AssertRespondTo + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.3 | - + +This cop enforces the use of `assert_respond_to(object, :some_method)` +over `assert(object.respond_to?(:some_method))`. + +### Examples + +```ruby +# bad +assert(object.respond_to?(:some_method)) +assert(object.respond_to?(:some_method), 'the message') + +# good +assert_respond_to(object, :some_method) +assert_respond_to(object, :some_method, 'the message') +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#assert-responds-to-method](https://github.com/rubocop-hq/minitest-style-guide#assert-responds-to-method) + ## Minitest/AssertTruthy Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.2 | - -Check if your test uses `assert(actual)` -instead of `assert_equal(true, actual)`. +This cop enforces the test to use `assert(actual)` +instead of using `assert_equal(true, actual)`. ### Examples ```ruby # bad @@ -96,16 +123,116 @@ ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-truthy](https://github.com/rubocop-hq/minitest-style-guide#assert-truthy) +## Minitest/RefuteEmpty + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.3 | - + +This cop enforces to use `refute_empty` instead of +using `refute(object.empty?)`. + +### Examples + +```ruby +# bad +refute(object.empty?) +refute(object.empty?, 'the message') + +# good +refute_empty(object) +refute_empty(object, 'the message') +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#refute-empty](https://github.com/rubocop-hq/minitest-style-guide#refute-empty) + +## Minitest/RefuteEqual + +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)`. + +### Examples + +```ruby +# bad +assert("rubocop-minitest" != actual) +assert(! "rubocop-minitest" == actual) + +# good +refute_equal("rubocop-minitest", actual) +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#refute-equal](https://github.com/rubocop-hq/minitest-style-guide#refute-equal) + +## Minitest/RefuteFalse + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.3 | - + +This cop enforces the use of `refute(object)` +over `assert_equal(false, object)`. + +### Examples + +```ruby +# bad +assert_equal(false, actual) +assert_equal(false, actual, 'the message') + +# good +refute(actual) +refute(actual, 'the message') +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#refute-false](https://github.com/rubocop-hq/minitest-style-guide#refute-false) + +## Minitest/RefuteIncludes + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.3 | - + +This cop enforces the test to use `refute_includes` +instead of using `refute(collection.include?(object))`. + +### Examples + +```ruby +# bad +refute(collection.include?(object)) +refute(collection.include?(object), 'the message') + +# good +refute_includes(collection, object) +refute_includes(collection, object, 'the message') +``` + +### References + +* [https://github.com/rubocop-hq/minitest-style-guide#refute-includes](https://github.com/rubocop-hq/minitest-style-guide#refute-includes) + ## Minitest/RefuteNil Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.2 | - -Check if your test uses `refute_nil` instead of `refute_equal(nil, something)`. +This cop enforces the test to use `refute_nil` +instead of using `refute_equal(nil, something)`. ### Examples ```ruby # bad