# File test/unit/assertions.rb, line 65 def assert_raises(expected_exception_klass, message="") _wrap_assertion { assert_instance_of(Class, expected_exception_klass, "Should expect a class of exception") actual_exception = nil full_message = build_message(message, expected_exception_klass) { | arg | "<#{arg}> exception expected but none was thrown" } assert_block(full_message) { thrown = false begin yield rescue Exception => thrown_exception actual_exception = thrown_exception thrown = true end thrown } full_message = build_message(message, expected_exception_klass, actual_exception) { | arg1, arg2 | "<#{arg1}> exception expected but was\n" + arg2 } assert_block(full_message) { expected_exception_klass == actual_exception.class } actual_exception } end