Sha256: 25f846f44cc5c987546438184aa034216d43dc54364d921349c47c78ecae746b
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Matchi # *Satisfy* matcher. class Satisfy # @return [Proc] A block of code. attr_reader :expected # Initialize the matcher with a block. # # @example # require "matchi/satisfy" # # Matchi::Satisfy.new { |value| value == 42 } # # @param block [Proc] A block of code. def initialize(&block) @expected = block end # 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. def matches? expected.call(yield) end # A string containing a human-readable representation of the matcher. def inspect "#{self.class}(&block)" end # Returns a string representing the matcher. def to_s "satisfy &block" end end end
Version data entries
6 entries across 6 versions & 1 rubygems