assert_raise(*args, &b) public

Tests if the given block raises an exception. Acceptable exception types maye 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

assert_raise NameError do
  puts x  #Raises NameError, so assertion succeeds
Show source
Register or log in to add new notes.