Sha256: 3e411882a46f4739be399fc14d5caf155f29a8ec09b5c6b5655e9ae525ac5298

Contents?: true

Size: 568 Bytes

Versions: 2

Compression:

Stored size: 568 Bytes

Contents

module Matchi
  # **Identity** matcher.
  class Equal < BasicObject
    # Initialize the matcher with an object.
    #
    # @example The number 42 matcher
    #   Matchi::Equal.new(42)
    #
    # @param [#equal?] expected an expected object
    def initialize(expected)
      @expected = expected
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

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