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.
Defined Under Namespace
Classes: Eql, Equal, Match, RaiseException
Class Method Summary collapse
-
.get(name) ⇒ Object
private
Get the class of a matcher from its symbol.
-
.pass?(negated, definition, &actual) ⇒ Boolean
private
Evaluate the expectation with the passed block.
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.
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.
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 |