Sha256: f7eec62f9e382a77c6e24c6183edfced8955003ce010f8b3dfaed0e0d44ca7c8
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module Matchi # *Satisfy* matcher. class Satisfy # 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.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
matchi-3.0.0 | lib/matchi/satisfy.rb |