Sha256: 791e32e41141d59aecd20d79e910aa6eb3708c67dda363b62d8c5c8d5c7c4d7e

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

require 'matchi'

module Expect
  # This module provides matchers to define expectations.
  module Matcher
    # Evaluate the expectation with the passed block.
    #
    # @param [Array, Hash, Symbol] definition
    #
    # @return [Boolean] report if the expectation is true or false
    def self.pass?(definition, &actual)
      params  = Array(definition).flatten(1)
      name    = params.first.to_s.split('_').map(&:capitalize).join.to_sym
      matcher = Matchi.fetch(name, *params[1..-1])

      matcher.matches?(&actual)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
expect-0.0.8 lib/expect/matcher.rb