# File test/unit/assertions.rb, line 296def assert_throws(expected_symbol, message="", &proc)
_wrap_assertion {
assert_instance_of(Symbol, expected_symbol, "assert_throws expects the symbol that should be thrown for its first argument")
assert(block_given?, "Should have passed a block to assert_throws")
caught = truebegin
catch(expected_symbol) {
proc.call
caught = false
}
full_message = build_message(message, expected_symbol) {
| arg |
"<:#{arg}> should have been thrown"
}
assert(caught, full_message)
rescue NameError => name_error
if ( name_error.message !~ /^uncaught throw `(.+)'$/ ) #`
raise name_error
end
full_message = build_message(message, expected_symbol, $1) {
| arg1, arg2 |
"<:#{arg1}> expected to be thrown but\n" +
"<:#{arg2}> was thrown"
}
flunk(full_message)
end
}
end