Sha256: e08ab2ff2da228faf3fe261da6b7f9be8429a5547195772153fe0646d25fa615

Contents?: true

Size: 812 Bytes

Versions: 4

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Minitest
      # Enforces the test to use `assert_kind_of(Class, object)`
      # over `assert(object.kind_of?(Class))`.
      #
      # @example
      #   # bad
      #   assert(object.kind_of?(Class))
      #   assert(object.kind_of?(Class), 'message')
      #
      #   # bad
      #   # `is_a?` is an alias for `kind_of?`
      #   assert(object.is_a?(Class))
      #   assert(object.is_a?(Class), 'message')
      #
      #   # good
      #   assert_kind_of(Class, object)
      #   assert_kind_of(Class, object, 'message')
      #
      class AssertKindOf < Base
        extend MinitestCopRule

        define_rule :assert, target_method: %i[kind_of? is_a?], preferred_method: :assert_kind_of, inverse: true
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-minitest-0.36.0 lib/rubocop/cop/minitest/assert_kind_of.rb
rubocop-minitest-0.35.1 lib/rubocop/cop/minitest/assert_kind_of.rb
rubocop-minitest-0.35.0 lib/rubocop/cop/minitest/assert_kind_of.rb
rubocop-minitest-0.34.5 lib/rubocop/cop/minitest/assert_kind_of.rb