Method: MotionSpec::Matcher::RaiseError#exception_matches

Defined in:
lib/motion-spec/matcher/raise_error.rb

#exception_matches(exception) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/motion-spec/matcher/raise_error.rb', line 22

def exception_matches(exception)
  return false unless exception.is_a?(@error_class)

  is_match =
    case @error_message
    when String
      exception.message.include?(@error_message)
    when Regexp
      @error_message.match(exception.message)
    else
      false
    end

  is_match ? true : false
end