Sha256: afdeb5a2bf573739bf6395658791d7814f665a97b25d8191f839a2cfd3cef6a2

Contents?: true

Size: 838 Bytes

Versions: 32

Compression:

Stored size: 838 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 # rubocop:disable InternalAffairs/UselessRestrictOnSend

        private

        def assertion_type
          'assert'
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
rubocop-minitest-0.26.0 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.25.1 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.25.0 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.24.0 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.23.2 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.23.1 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.23.0 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.22.2 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.22.1 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.22.0 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.21.1 lib/rubocop/cop/minitest/assert_predicate.rb
rubocop-minitest-0.21.0 lib/rubocop/cop/minitest/assert_predicate.rb