Module: Ramcrest::Matcher

Defined Under Namespace

Classes: MatchResult

Instance Method Summary collapse

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

Returns:

  • (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(mismatch_message(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

#successObject



17
18
19
# File 'lib/ramcrest/matcher.rb', line 17

def success
  MatchResult::SUCCESS
end