Sha256: b53212a15b784cfeb4865176545abaf0001d8a2fffa18f7c179b63adc0d63479

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

require_relative File.join 'support', 'coverage'
require_relative File.join '..', 'lib', 'matchi'

module Matchi
  # **Answer to the Ultimate Question of Life, The Universe, and Everything**
  # matcher.
  class BeTheAnswer
    # @example Is it 42?
    #   be_the_answer = Matchi::BeTheAnswer.new
    #   be_the_answer.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?
      42.equal? yield
    end
  end
end

# It is expected to be true
fail unless Matchi.fetch(:BeTheAnswer).matches? { 42 }

# It is expected to be false
fail if Matchi.fetch(:BeTheAnswer).matches? { 4 }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
matchi-0.0.6 test/test_be_the_answer.rb