Sha256: 6cbe06b61afe8724207b5bf27d9a14353190c628600c46bb4728819f50e305cc

Contents?: true

Size: 582 Bytes

Versions: 2

Compression:

Stored size: 582 Bytes

Contents

module Matchi
  # **Equivalence** matcher.
  class Eql < BasicObject
    # Initialize the matcher with an object.
    #
    # @example The string 'foo' matcher
    #   Matchi::Eql.new('foo')
    #
    # @param [#eql?] expected an expected equivalent object
    def initialize(expected)
      @expected = expected
    end

    # @example Is it equivalent to 'foo'?
    #   eql = Matchi::Eql.new('foo')
    #   eql.matches? { 'foo' } # => true
    #
    # @return [Boolean] Comparison between actual and expected values.
    def matches?
      @expected.eql?(yield)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
matchi-0.0.5 lib/matchi/eql.rb
matchi-0.0.4 lib/matchi/eql.rb