Sha256: c2fb6477e9f5d0e1acd345eefd0061bd9f2c1cd4cb838c1c52ce40da4c7c0a56

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

require 'matchi'

module Spectus
  # 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

1 entries across 1 versions & 1 rubygems

Version Path
spectus-2.0.3 lib/spectus/matcher.rb