Class: RuboCop::Cop::Minitest::AssertInstanceOf

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
InstanceOfAssertionHandleable
Defined in:
lib/rubocop/cop/minitest/assert_instance_of.rb

Overview

Enforces the test to use ‘assert_instance_of(Class, object)` over `assert(object.instance_of?(Class))`.

Examples:

# bad
assert(object.instance_of?(Class))
assert(object.instance_of?(Class), 'message')

# bad
assert_equal(Class, object.class)
assert_equal(Class, object.class, 'message')

# good
assert_instance_of(Class, object)
assert_instance_of(Class, object, 'message')

Constant Summary collapse

RESTRICT_ON_SEND =
%i[assert assert_equal].freeze

Constants included from InstanceOfAssertionHandleable

InstanceOfAssertionHandleable::MSG

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



35
36
37
# File 'lib/rubocop/cop/minitest/assert_instance_of.rb', line 35

def on_send(node)
  investigate(node, :assert)
end