Sha256: a6909f58c2c6d49d07519b9aa8ceb7aaca7a32473fe2a71fcf1375b66b0f27c7

Contents?: true

Size: 790 Bytes

Versions: 5

Compression:

Stored size: 790 Bytes

Contents

require 'matchi'
require 'fix'

# Namespace for the Matchi library.
#
# @api public
#
module Matchi
  # Initialize the matcher with a spec compatible with Fix DSL.
  #
  # @api public
  #
  class Fix
    # Initialize the matcher.
    #
    # @api private
    #
    def initialize(expected)
      @expected = expected
    end

    # @example Is it equal to 42?
    #   fix = Matchi::Fix.new(proc { it { MUST Equal: 42 } })
    #   fix.matches? { 6 * 7 } # => true
    #
    # @api public
    #
    # @yieldreturn [#object_id] The front object to compare against the spec.
    #
    # @return [Boolean] The result of the test which can be _pass_ or _fail_.
    def matches?
      ::Fix.describe(yield, verbose: false, &@expected)
    rescue SystemExit => e
      e.success?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
matchi-fix-0.1.5 lib/matchi/fix.rb
matchi-fix-0.1.4 lib/matchi/fix.rb
matchi-fix-0.1.3 lib/matchi/fix.rb
matchi-fix-0.1.2 lib/matchi/fix.rb
matchi-fix-0.1.1 lib/matchi/fix.rb