Module: Expect::Matcher Private

Defined in:
lib/expect/matcher.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This module provides matchers to define expectations.

Class Method Summary collapse

Class Method Details

.get(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the class of a matcher from its symbol.

Examples:


Matcher.get(:eql) # => Eql


25
26
27
# File 'lib/expect/matcher.rb', line 25

def self.get(name)
  Matchi.const_get name.to_s.split('_').map(&:capitalize).join.to_sym
end

.pass?(definition, &actual) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluate the expectation with the passed block.

Parameters:

  • definition (Hash)

Returns:

  • (Boolean)

    Report if the expectation is true or false.



11
12
13
14
15
16
17
18
# File 'lib/expect/matcher.rb', line 11

def self.pass?(definition, &actual)
  params        = Array(definition).flatten 1
  name          = params.first
  expected_args = params[1..-1]
  matcher       = get(name).new(*expected_args)

  matcher.matches?(&actual)
end