From: Sean Carley Date: 2006-03-09T06:42:52+09:00 Subject: assert_raise question ------=_Part_5477_6620019.1141854155416 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Currently, assert_raise expects you to know exactly what kind of exception is going to be thrown by raise. Basically it tests to see if exception.class =3D=3D expected.class. I think a more appropriate behavior would be to test exception.kind_of?expected. I would also be happy if there were one method that performed the way it does currently and another that checks exception parentage. Please see the code below for an example of two tests. I think both should pass but only the first test does because ArgumentError !=3D StandardError. Sean Carley ### Begin test.rb ### require 'test/unit' class TestRaise < Test::Unit::TestCase def test_raise assert_raise(ArgumentError){raise ArgumentError.new("basic argument issue")} end def test_raise_parent assert_raise(StandardError){raise ArgumentError.new("basic argument issue")} end end ### End test.rb ### > ruby test.rb Loaded suite test Started .F Finished in 0.018356 seconds. 1) Failure: test_raise_parent(TestRaise) [test.rb:7]: exception expected but was Class: Message: <"basic argument issue"> ---Backtrace--- test.rb:7:in `test_raise_parent' test.rb:7:in `test_raise_parent' --------------- 2 tests, 2 assertions, 1 failures, 0 errors ------=_Part_5477_6620019.1141854155416--