# File test/unit/assertions.rb, line 260 def assert_throws(expected_symbol, message="", &proc) _wrap_assertion { assert_instance_of(Symbol, expected_symbol, "assertThrows expects the symbol that should be thrown for its first argument") assert(block_given?, "Should have passed a block to assertThrows") caught = true begin 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 | "Expected <:#{arg1}> to be thrown but <:#{arg2}> was thrown" } flunk(full_message) end } end