Sha256: ae8c42e25d26d03802dd2513979eed2a5f83948774e8171f47e7e61efa8d23b7
Contents?: true
Size: 1007 Bytes
Versions: 53
Compression:
Stored size: 1007 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module RSpec # Checks for equality assertions with identical expressions on both sides. # # @example # # bad # expect(foo.bar).to eq(foo.bar) # expect(foo.bar).to eql(foo.bar) # # # good # expect(foo.bar).to eq(2) # expect(foo.bar).to eql(2) # class IdenticalEqualityAssertion < Base MSG = 'Identical expressions on both sides of the equality ' \ 'may indicate a flawed test.' RESTRICT_ON_SEND = %i[to].freeze # @!method equality_check?(node) def_node_matcher :equality_check?, <<~PATTERN (send (send nil? :expect $_) :to {(send nil? {:eql :eq :be} $_) (send (send nil? :be) :== $_)}) PATTERN def on_send(node) equality_check?(node) do |left, right| add_offense(node) if left == right end end end end end end
Version data entries
53 entries across 51 versions & 7 rubygems