Class: Ramcrest::MatcherMatcher::MatcherThatMismatchesMatcher

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, description) ⇒ MatcherThatMismatchesMatcher

Returns a new instance of MatcherThatMismatchesMatcher.



62
63
64
65
# File 'lib/ramcrest/matcher_matcher.rb', line 62

def initialize(value, description)
  @value = value
  @description = description
end

Instance Method Details

#descriptionObject



80
81
82
# File 'lib/ramcrest/matcher_matcher.rb', line 80

def description
  "a matcher that mismatches <#{@value}> explained by \"#{@description}\""
end

#matches?(matcher) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ramcrest/matcher_matcher.rb', line 67

def matches?(matcher)
  match = matcher.matches?(@value)
  if match.matched?
    mismatch("the matcher matched")
  else
    if match.description == @description
      success
    else
      mismatch("the mismatch description was \"#{match.description}\"")
    end
  end
end