Class: Matchi::Matchers::Eql::Matcher

Inherits:
Object
  • Object
show all
Includes:
Matchi::MatchersBase
Defined in:
lib/matchi/matchers/eql.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 string ‘foo’ matcher.

Matchi::Matchers::Eql::Matcher.new('foo')

Parameters:

  • expected (#eql?)

    An expected equivalent object.



18
19
20
# File 'lib/matchi/matchers/eql.rb', line 18

def initialize(expected)
  @expected = expected
end

Instance Method Details

#matches?Boolean

Boolean comparison between the actual value and the expected value.

Examples:

Is it equivalent to ‘foo’?

eql = Matchi::Matchers::Eql::Matcher.new('foo')
eql.matches? { 'foo' } # => true

Yield Returns:

  • (#object_id)

    the actual value to compare to the expected one.

Returns:

  • (Boolean)

    Comparison between actual and expected values.



32
33
34
# File 'lib/matchi/matchers/eql.rb', line 32

def matches?
  @expected.eql?(yield)
end