Class: Ramcrest::MatcherMatcher::MatcherThatMatchesMatcher

Inherits:
Object
  • Object
show all
Includes:
Ramcrest::Matcher
Defined in:
lib/ramcrest/matcher_matcher.rb

Instance Method Summary collapse

Methods included from Ramcrest::Matcher

#do_match, #mismatch, #success

Constructor Details

#initialize(value) ⇒ MatcherThatMatchesMatcher

Returns a new instance of MatcherThatMatchesMatcher.



21
22
23
# File 'lib/ramcrest/matcher_matcher.rb', line 21

def initialize(value)
  @value = value
end

Instance Method Details

#descriptionObject



34
35
36
# File 'lib/ramcrest/matcher_matcher.rb', line 34

def description
  "a matcher that matches <#{@value}>"
end

#matches?(matcher) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
# File 'lib/ramcrest/matcher_matcher.rb', line 25

def matches?(matcher)
  match = matcher.matches?(@value)
  if match.matched?
    success
  else
    mismatch("a matcher describing itself as <#{matcher.description}> that mismatched with <#{match.description}>")
  end
end