Daniel Berger
2/16/2007 7:14:00 PM
On Feb 16, 11:17 am, Edwin Fine <efine145-nospa...@usa.net> wrote:
> Some time ago, I complained about assert_raise requiring one to list
> specific exceptions in a test case. My issue is that I wanted to test
> for the raising of a base exception OR any exception derived from that
> base exception, because I did not want to have to change the unit tests
> every time a different exception subclass is thrown by the method under
> test or anything it calls.
>
> I dynamically added a new assert function to Test::Unit, named
> assert_raise_s, which works this way. It should not break any existing
> Test::Unit functionality. At least one person emailed me and asked me to
> provide the code for this function, so I am posting it here in case
> others might want it, too. I think that Daniel Berger also talked about
> needing something like this some time ago (he wasn't the person who
> emailed me).
Yep, In my case I would like this functionality for validating system
errors (i.e. Errno::) where you don't know in advance exactly what
type of Errno a given method is going to raise because they can be
platform specific.
> In your test case file(s), you just need to
<snip>
Nice. Can you please re-tool this as a patch to test-unit and submit
it to ruby-core?
Thanks,
Dan