Class: Matchi::Matchers::Equal::Matcher

Inherits:
Object
  • Object
show all
Includes:
Matchi::MatchersBase
Defined in:
lib/matchi/matchers/equal.rb

Overview

The matcher.

Instance Method Summary collapse

Methods included from Matchi::MatchersBase

#to_h, #to_s

Constructor Details

#initialize(expected) ⇒ Matcher

Initialize the matcher with an object.

Examples:

The number 42 matcher.

Matchi::Matchers::Equal::Matcher.new(42)

Parameters:

  • expected (#equal?)

    An expected object.



20
21
22
# File 'lib/matchi/matchers/equal.rb', line 20

def initialize(expected)
  @expected = expected
end

Instance Method Details

#matches?Boolean

Boolean comparison between the actual value and the expected value.

Examples:

Is it equal to :foo?

equal = Matchi::Matchers::Equal::Matcher.new(:foo)
equal.matches? { :foo } # => true

Yield Returns:

  • (#object_id)

    The actual value to compare to the expected one.

Returns:

  • (Boolean)

    Comparison between actual and expected values.



34
35
36
# File 'lib/matchi/matchers/equal.rb', line 34

def matches?(*, **)
  @expected.equal?(yield)
end