Sha256: 57f54599b17b46405e7ecb1b767e84738b183d8c1022a975622f42d61de2e8c8
Contents?: true
Size: 1.08 KB
Versions: 16
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Minitest # Enforces the test to use `assert_instance_of(Class, object)` # over `assert(object.instance_of?(Class))`. # # @example # # 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') # class AssertInstanceOf < Base include InstanceOfAssertionHandleable extend AutoCorrector RESTRICT_ON_SEND = %i[assert assert_equal].freeze def_node_matcher :instance_of_assertion?, <<~PATTERN { (send nil? :assert (send $_ :instance_of? $const) $_?) (send nil? :assert_equal $const (send $_ :class) $_?) } PATTERN def on_send(node) investigate(node, :assert) end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems