manual/cops_minitest.md in rubocop-minitest-0.6.2 vs manual/cops_minitest.md in rubocop-minitest-0.7.0

- old
+ new

@@ -12,15 +12,15 @@ ### Examples ```ruby # bad assert(object.empty?) -assert(object.empty?, 'the message') +assert(object.empty?, 'message') # good assert_empty(object) -assert_empty(object, 'the message') +assert_empty(object, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-empty](https://github.com/rubocop-hq/minitest-style-guide#assert-empty) @@ -80,15 +80,15 @@ ### Examples ```ruby # bad assert(collection.include?(object)) -assert(collection.include?(object), 'the message') +assert(collection.include?(object), 'message') # good assert_includes(collection, object) -assert_includes(collection, object, 'the message') +assert_includes(collection, object, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-includes](https://github.com/rubocop-hq/minitest-style-guide#assert-includes) @@ -105,15 +105,15 @@ ### Examples ```ruby # bad assert(object.instance_of?(Class)) -assert(object.instance_of?(Class), 'the message') +assert(object.instance_of?(Class), 'message') # good assert_instance_of(Class, object) -assert_instance_of(Class, object, 'the message') +assert_instance_of(Class, object, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of](https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of) @@ -130,15 +130,15 @@ ### Examples ```ruby # bad assert(matcher.match(string)) -assert(matcher.match(string), 'the message') +assert(matcher.match(string), 'message') # good assert_match(regex, string) -assert_match(matcher, string, 'the message') +assert_match(matcher, string, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-match](https://github.com/rubocop-hq/minitest-style-guide#assert-match) @@ -155,15 +155,15 @@ ### Examples ```ruby # bad assert_equal(nil, actual) -assert_equal(nil, actual, 'the message') +assert_equal(nil, actual, 'message') # good assert_nil(actual) -assert_nil(actual, 'the message') +assert_nil(actual, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-nil](https://github.com/rubocop-hq/minitest-style-guide#assert-nil) @@ -172,25 +172,25 @@ 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))`. +This cop enforces the use of `assert_respond_to(object, :do_something)` +over `assert(object.respond_to?(:do_something))`. ### Examples ```ruby # bad -assert(object.respond_to?(:some_method)) -assert(object.respond_to?(:some_method), 'the message') -assert(respond_to?(:some_method)) +assert(object.respond_to?(:do_something)) +assert(object.respond_to?(:do_something), 'message') +assert(respond_to?(:do_something)) # good -assert_respond_to(object, :some_method) -assert_respond_to(object, :some_method, 'the message') -assert_respond_to(self, some_method) +assert_respond_to(object, :do_something) +assert_respond_to(object, :do_something, 'message') +assert_respond_to(self, :do_something) ``` ### 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) @@ -207,21 +207,42 @@ ### Examples ```ruby # bad assert_equal(true, actual) -assert_equal(true, actual, 'the message') +assert_equal(true, actual, 'message') # good assert(actual) -assert(actual, 'the message') +assert(actual, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#assert-truthy](https://github.com/rubocop-hq/minitest-style-guide#assert-truthy) +## Minitest/GlobalExpectations + +Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged +--- | --- | --- | --- | --- +Enabled | Yes | Yes | 0.7 | - + +This Cop checks for deprecated global expectations +and autocorrects them to use expect format. + +### Examples + +```ruby +# bad +n.must_equal 42 +n.wont_match b + +# good +_(n).must_equal 42 +_(n).wont_match b +``` + ## Minitest/RefuteEmpty Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- Enabled | Yes | Yes | 0.3 | - @@ -232,15 +253,15 @@ ### Examples ```ruby # bad refute(object.empty?) -refute(object.empty?, 'the message') +refute(object.empty?, 'message') # good refute_empty(object) -refute_empty(object, 'the message') +refute_empty(object, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-empty](https://github.com/rubocop-hq/minitest-style-guide#refute-empty) @@ -281,18 +302,18 @@ ### Examples ```ruby # bad assert_equal(false, actual) -assert_equal(false, actual, 'the message') +assert_equal(false, actual, 'message') assert(!test) -assert(!test, 'the message') +assert(!test, 'message') # good refute(actual) -refute(actual, 'the message') +refute(actual, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-false](https://github.com/rubocop-hq/minitest-style-guide#refute-false) @@ -309,15 +330,15 @@ ### Examples ```ruby # bad refute(collection.include?(object)) -refute(collection.include?(object), 'the message') +refute(collection.include?(object), 'message') # good refute_includes(collection, object) -refute_includes(collection, object, 'the message') +refute_includes(collection, object, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-includes](https://github.com/rubocop-hq/minitest-style-guide#refute-includes) @@ -334,15 +355,15 @@ ### Examples ```ruby # bad refute(object.instance_of?(Class)) -refute(object.instance_of?(Class), 'the message') +refute(object.instance_of?(Class), 'message') # good refute_instance_of(Class, object) -refute_instance_of(Class, object, 'the message') +refute_instance_of(Class, object, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of](https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of) @@ -359,15 +380,15 @@ ### Examples ```ruby # bad refute(matcher.match(string)) -refute(matcher.match(string), 'the message') +refute(matcher.match(string), 'message') # good refute_match(matcher, string) -refute_match(matcher, string, 'the message') +refute_match(matcher, string, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-match](https://github.com/rubocop-hq/minitest-style-guide#refute-match) @@ -384,15 +405,15 @@ ### Examples ```ruby # bad refute_equal(nil, actual) -refute_equal(nil, actual, 'the message') +refute_equal(nil, actual, 'message') # good refute_nil(actual) -refute_nil(actual, 'the message') +refute_nil(actual, 'message') ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-nil](https://github.com/rubocop-hq/minitest-style-guide#refute-nil) @@ -401,24 +422,24 @@ 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))`. +This cop enforces the test to use `refute_respond_to(object, :do_something)` +over `refute(object.respond_to?(:do_something))`. ### Examples ```ruby # bad -refute(object.respond_to?(:some_method)) -refute(object.respond_to?(:some_method), 'the message') -refute(respond_to?(:some_method)) +refute(object.respond_to?(:do_something)) +refute(object.respond_to?(:do_something), 'message') +refute(respond_to?(:do_something)) # good -refute_respond_to(object, :some_method) -refute_respond_to(object, :some_method, 'the message') -refute_respond_to(self, :some_method) +refute_respond_to(object, :do_something) +refute_respond_to(object, :do_something, 'message') +refute_respond_to(self, :do_something) ``` ### References * [https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to](https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to)