Sha256: 2b9b712085d1966e1caf73d90b29218b0ea1072657333665a19a89e6ec5ab4d2

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Minitest
      # Enforces the test to use `assert_predicate`
      # instead of using `assert(obj.a_predicate_method?)`.
      #
      # @example
      #   # bad
      #   assert(obj.one?)
      #   assert(obj.one?, 'message')
      #
      #   # good
      #   assert_predicate(obj, :one?)
      #   assert_predicate(obj, :one?, 'message')
      #
      class AssertPredicate < Base
        include ArgumentRangeHelper
        include PredicateAssertionHandleable
        extend AutoCorrector

        MSG = 'Prefer using `assert_predicate(%<new_arguments>s)`.'
        RESTRICT_ON_SEND = %i[assert].freeze

        private

        def assertion_type
          'assert'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-minitest-0.20.1 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.20.0 lib/rubocop/cop/minitest/assert_predicate.rb