Sha256: 80393fbcd70a05a3f390d83e73ae5d06a83689740c0e86c6ba36152dfd65b7e8

Contents?: true

Size: 603 Bytes

Versions: 2

Compression:

Stored size: 603 Bytes

Contents

require 'matchi'

module Expect
  # This module provides matchers to define expectations.
  module Matcher
    # Evaluate the expectation with the passed block.
    #
    # @param [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
      expected_args = params[1..-1]
      matcher       = Matchi.const_get(name).new(*expected_args)

      matcher.matches?(&actual)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
expect-0.0.7 lib/expect/matcher.rb
expect-0.0.6 lib/expect/matcher.rb