--- assert_raise version 2 Fri Feb 05 00:11:12 -0800 2010
+++ assert_raise version 3 Thu Jun 03 07:35:40 -0700 2010
@@ -1,21 +1,26 @@
# 'cheat assertions' for the rest
assert_raise(*args) {|| ...}
Passes if the block raises one of the given exceptions.
-Returns the thrown exception but there seems to
-be no simply way of checking the message of the
-exception using this assertion.
+Returns the thrown exception.
Examples:
assert_raise RuntimeError, LoadError do
raise 'Boom!!!'
end
assert_raise(ActionController::RoutingError) {
assert_routing 'invalid/url', { }
}
+
+ # to check the message/class of the exception
+ exception = assert_raise RuntimeError, LoadError do
+ ...
+ end
+ puts exception.message
+ puts exception.class