# File test/unit/assertions.rb, line 60 def assert_raises(expected_exception_klass, message="") _wrap_assertion { assert_instance_of(Class, expected_exception_klass, "Should expect a type of exception") actual_exception = nil full_message = build_message(message, expected_exception_klass) { | arg | "Expected exception of type <#{arg}> 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.class.name, actual_exception.message, actual_exception.backtrace.join("\n\t")) { | arg1, arg2, arg3, arg4 | "Expected exception to be of type <#{arg1}> but was <#{arg2}: #{arg3}\n\t#{arg4}>" } assert_block(full_message) { expected_exception_klass == actual_exception.class } actual_exception } end