Using MiniTest spec, I can test that code raises a specific exception as follows:
proc { foo.do_bar }.must_raise SomeException
But, I don't care what the specific exception is, I just want to verify that some exception is thrown. If I, or another developer, decides to change what exception is thrown by Foo#do_bar, my test wouldn't have to change if the expected exception was specified generally enough.
That is, I would like to write the test this way (Exception is an ancestor of class SomeException):
proc { foo.do_bar }.must_raise Exception
By this results in a failure when I run the test:
[Exception] exception expected, not
Class: <SomeException>
Can I write my Minitest spec more generically with regards to exceptions?
(The actual reason I want to check for any exception, rather than a specific exception, is that I'm using a third party Gem, and it is that code that raises the exception. In fact, my method A gets called by third party method B. A raises MyException, however B catches that exception, and re-raises a different exception. This exception has the same message as my exception [and this message is something I ought to verify in the test], but a different class.)