Method: RubyUnit::Assertions::Exceptions#assertRaiseExpected
- Defined in:
- lib/RubyUnit/Assertions/Exceptions.rb
#assertRaiseExpected(exception, pattern, message = nil, &block) ⇒ Object
Assert that a specified exception is raised.
-
raises RubyUnit::AssertionFailure unless the correct Exception is raised
- exception
-
The Exception class that is expected.
- pattern
-
The String or Regexp that will be used to validate the Exception message
- message
-
The message provided to be reported for a failure
- &block
-
The code block that is expected to throw the Exception
assertRaiseExpected StandardError, /^Invalid/, 'Expecting an exception!' do
raise StandardError, 'Invalid Retroincabulator'
end
96 97 98 |
# File 'lib/RubyUnit/Assertions/Exceptions.rb', line 96 def assertRaiseExpected exception, pattern, = nil, &block __assert_exception ASSERT_RAISE_EXPECTED_ERROR, exception, pattern, , &block end |