lib/matchi/eq.rb in matchi-3.0.0 vs lib/matchi/eq.rb in matchi-3.1.0

- old
+ new

@@ -1,10 +1,13 @@ # frozen_string_literal: true module Matchi # *Equivalence* matcher. class Eq + # @return [#eql?] An expected equivalent object. + attr_reader :expected + # Initialize the matcher with an object. # # @example # require "matchi/eq" # @@ -19,26 +22,28 @@ # # @example # require "matchi/eq" # # matcher = Matchi::Eq.new("foo") + # + # matcher.expected # => "foo" # matcher.matches? { "foo" } # => true # # @yieldreturn [#object_id] The actual value to compare to the expected # one. # # @return [Boolean] Comparison between actual and expected values. - def matches?(*, **) - @expected.eql?(yield) + def matches? + expected.eql?(yield) end # A string containing a human-readable representation of the matcher. def inspect - "#{self.class}(#{@expected.inspect})" + "#{self.class}(#{expected.inspect})" end # Returns a string representing the matcher. def to_s - "eq #{@expected.inspect}" + "eq #{expected.inspect}" end end end