assert_raise(*args, &b) public

Tests if the given block raises an exception. Acceptable exception types may be given as optional arguments. If the last argument is a String, it will be used as the error message.

assert_raise do #Fails, no Exceptions are raised
end

assert_raise NameError do
  puts x  #Raises NameError, so assertion succeeds
end
Show source
Register or log in to add new notes.
April 2, 2015
0 thanks

Typo

“Acceptable exception types maye be given as optional arguments. If the last argument is a String, it will be used as the error message.”

>

“Acceptable exception types may be given as optional arguments. If the last argument is a String, it will be used as the error message.”