From: Warren Brown Date: 2003-05-24T07:07:42+09:00 Subject: Test::Unit assert_raises issues 1.6.8 => 1.8 I have some test cases in Ruby version 1.6.8 that are of the form: class Foo; end assert_raises(NameError) { Foo.undefinedmethod } Basically, I want to make sure that a particular operation (i.e. method invocation) does *not* work and raises an exception. Apparently in Ruby 1.8, the exception raised in this case has been changed to NoMethodError. It is easy enough for me to go and change all of the occurrences of "assert_raises(NameError)" to "assert_raises(NoMethodError)", to make this work under 1.8, but I really would like to have the test cases work under both 1.6.8 and 1.8. Since the Exception class name is a required parameter for Test::Unit#assert_raises it looks like I am going to have to create a constant somewhere like: NoMethodException = (VERSION == 1.8) ? NoMethodError : NameError ... and then use that constant instead of the actual exception name: assert_raises(NoMethodException) { ... } This will work, but is messy. Anyone else see a prettier way to do this? What would be really nice is if Test::Unit#asser_raises also accepted zero parameters (true if *any* exception raised). Any chance of getting this Nathaniel? Thanks in advance... - Warren Brown