method
assert_raise_with_message
ruby latest stable - Class:
Test::Unit::Assertions
assert_raise_with_message(exception, expected, msg = nil, &block)public
Tests if the given block raises an exception with the expected message.
assert_raise_with_message(RuntimeError, "foo") do nil #Fails, no Exceptions are raised end assert_raise_with_message(RuntimeError, "foo") do raise ArgumentError, "foo" #Fails, different Exception is raised end assert_raise_with_message(RuntimeError, "foo") do raise "bar" #Fails, RuntimeError is raised but the message differs end assert_raise_with_message(RuntimeError, "foo") do raise "foo" #Raises RuntimeError with the message, so assertion succeeds end