class Matchi::Satisfy

Satisfy matcher.

Attributes

expected[R]

@return [Proc] A block of code.

Public Class Methods

new(&block) click to toggle source

Initialize the matcher with a block.

@example

require "matchi/satisfy"

Matchi::Satisfy.new { |value| value == 42 }

@param block [Proc] A block of code.

# File lib/matchi/satisfy.rb, line 17
def initialize(&block)
  @expected = block
end

Public Instance Methods

inspect() click to toggle source

A string containing a human-readable representation of the matcher.

# File lib/matchi/satisfy.rb, line 40
def inspect
  "#{self.class}(&block)"
end
matches?() { || ... } click to toggle source

Boolean comparison between the actual value and the expected value.

@example

require "matchi/satisfy"

matcher = Matchi::Satisfy.new { |value| value == 42 }

matcher.expected        # => #<Proc:0x00007fbaafc65540>
matcher.matches? { 42 } # => true

@yieldreturn [#object_id] The actual value to compare to the expected

one.

@return [Boolean] Comparison between actual and expected values.

# File lib/matchi/satisfy.rb, line 35
def matches?
  expected.call(yield)
end
to_s() click to toggle source

Returns a string representing the matcher.

# File lib/matchi/satisfy.rb, line 45
def to_s
  "satisfy &block"
end