Module: Ramcrest::Matcher
- Included in:
- Aint::Matcher, Anything::Matcher, Comparable::Matcher, Enumerable::BaseEnumerableMatcher, EqualTo::Matcher, HasAttribute::Matcher, HasSize::Matcher, Is::Matcher, Ramcrest::MatcherMatcher::MatcherDescribedAsMatcher, Ramcrest::MatcherMatcher::MatcherThatMatchesMatcher, Ramcrest::MatcherMatcher::MatcherThatMismatchesMatcher, SuchThat::Matcher
- Defined in:
- lib/ramcrest/matcher.rb
Defined Under Namespace
Classes: MatchResult
Instance Method Summary collapse
- #do_match(expected, actual) ⇒ Object
- #matches?(actual) ⇒ Boolean
- #mismatch(description) ⇒ Object
- #success ⇒ Object
Instance Method Details
#do_match(expected, actual) ⇒ Object
4 5 6 |
# File 'lib/ramcrest/matcher.rb', line 4 def do_match(expected, actual) expected.matches?(actual) end |
#matches?(actual) ⇒ Boolean
8 9 10 11 12 13 14 15 |
# File 'lib/ramcrest/matcher.rb', line 8 def matches?(actual) match = do_match(@expected, actual) if match.matched? success else mismatch((actual, match)) end end |
#mismatch(description) ⇒ Object
21 22 23 |
# File 'lib/ramcrest/matcher.rb', line 21 def mismatch(description) MatchResult.new(false, description) end |
#success ⇒ Object
17 18 19 |
# File 'lib/ramcrest/matcher.rb', line 17 def success MatchResult::SUCCESS end |