Sha256: a55b2d23c6fdc7d35e49c0a451a0cda3f0b10ff637816cc9542851fb7d21535f

Contents?: true

Size: 652 Bytes

Versions: 12

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Minitest
      # Enforces the use of `assert_same(expected, actual)`
      # over `assert(expected.equal?(actual))`.
      #
      # NOTE: Use `assert_same` only when there is a need to compare by identity.
      #       Otherwise, use `assert_equal`.
      #
      # @example
      #   # bad
      #   assert(expected.equal?(actual))
      #
      #   # good
      #   assert_same(expected, actual)
      #
      class AssertSame < Base
        extend MinitestCopRule

        define_rule :assert, target_method: :equal?, preferred_method: :assert_same
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubocop-minitest-0.33.0 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.32.2 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.32.1 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.32.0 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.31.1 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.31.0 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.30.0 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.29.0 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.28.0 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.27.0 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.26.1 lib/rubocop/cop/minitest/assert_same.rb
rubocop-minitest-0.26.0 lib/rubocop/cop/minitest/assert_same.rb