lib/rubocop/cop/minitest/refute_nil.rb in rubocop-minitest-0.17.2 vs lib/rubocop/cop/minitest/refute_nil.rb in rubocop-minitest-0.18.0
- old
+ new
@@ -2,18 +2,20 @@
module RuboCop
module Cop
module Minitest
# This cop enforces the test to use `refute_nil` instead of using
- # `refute_equal(nil, something)` or `refute(something.nil?)`.
+ # `refute_equal(nil, something)`, `refute(something.nil?)`, or `refute_predicate(something, :nil?)`.
#
# @example
# # bad
# refute_equal(nil, actual)
# refute_equal(nil, actual, 'message')
# refute(actual.nil?)
# refute(actual.nil?, 'message')
+ # refute_predicate(object, :nil?)
+ # refute_predicate(object, :nil?, 'message')
#
# # good
# refute_nil(actual)
# refute_nil(actual, 'message')
#
@@ -21,15 +23,16 @@
include ArgumentRangeHelper
include NilAssertionHandleable
extend AutoCorrector
ASSERTION_TYPE = 'refute'
- RESTRICT_ON_SEND = %i[refute_equal refute].freeze
+ RESTRICT_ON_SEND = %i[refute refute_equal refute_predicate].freeze
def_node_matcher :nil_refutation, <<~PATTERN
{
(send nil? :refute_equal nil $_ $...)
(send nil? :refute (send $_ :nil?) $...)
+ (send nil? :refute_predicate $_ (sym :nil?) $...)
}
PATTERN
def on_send(node)
nil_refutation(node) do |actual, message|