Module: Expect::Matcher Private

Defined in:
lib/expect/matcher.rb,
lib/expect/matcher/eql.rb,
lib/expect/matcher/equal.rb,
lib/expect/matcher/match.rb,
lib/expect/matcher/raise_exception.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.

API:

  • private

Defined Under Namespace

Classes: Eql, Equal, Match, RaiseException

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

API:

  • private



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

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

.pass?(negated, 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:

Returns:

  • Report if the expectation is true or false.

API:

  • private



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

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

  negated ^ matcher.matches?(&actual)
end