class Matchi::Be

Identity matcher.

Attributes

expected[R]

@return [#equal?] The expected identical object.

Public Class Methods

new(expected) click to toggle source

Initialize the matcher with an object.

@example

require "matchi/be"

Matchi::Be.new(:foo)

@param expected [#equal?] The expected identical object.

# File lib/matchi/be.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/be.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/be"

matcher = Matchi::Be.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/be.rb, line 35
def matches?
  expected.equal?(yield)
end
to_s() click to toggle source

Returns a string representing the matcher.

# File lib/matchi/be.rb, line 45
def to_s
  "be #{expected.inspect}"
end