Class: Ramcrest::MatcherMatcher::MatcherDescribedAsMatcher

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(description) ⇒ MatcherDescribedAsMatcher

Returns a new instance of MatcherDescribedAsMatcher.



42
43
44
# File 'lib/ramcrest/matcher_matcher.rb', line 42

def initialize(description)
  @description = description
end

Instance Method Details

#descriptionObject



54
55
56
# File 'lib/ramcrest/matcher_matcher.rb', line 54

def description
  "a matcher described as \"#{@description}\""
end

#matches?(matcher) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
# File 'lib/ramcrest/matcher_matcher.rb', line 46

def matches?(matcher)
  if matcher.description == @description
    success
  else
    mismatch("a matcher that described itself as \"#{matcher.description}\"")
  end
end