class Matchi::Eq
Equivalence matcher.
Attributes
expected[R]
@return [#eql?] An expected equivalent object.
Public Class Methods
new(expected)
click to toggle source
Initialize the matcher with an object.
@example
require "matchi/eq" Matchi::Eq.new("foo")
@param expected [#eql?] An expected equivalent object.
# File lib/matchi/eq.rb, line 17 def initialize(expected) @expected = expected end
Public Instance Methods
inspect()
click to toggle source
A string containing a human-readable representation of the matcher.
# File lib/matchi/eq.rb, line 40 def inspect "#{self.class}(#{expected.inspect})" end
matches?() { || ... }
click to toggle source
Boolean comparison between the actual value and the expected value.
@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.
# File lib/matchi/eq.rb, line 35 def matches? expected.eql?(yield) end
to_s()
click to toggle source
Returns a string representing the matcher.
# File lib/matchi/eq.rb, line 45 def to_s "eq #{expected.inspect}" end