ColdSpring throws coldspring.NoSuchBeanDefinition when you request a non-existent bean, e.g., Wibble, but it uses an empty message and a detail of "Bean definition for bean named: Wibble could not be found."
Assertion.throws() will not match any empty message: reFindNoCase( "", "" ) returns zero, as does reFindNoCase( "^$", "" ) so it seems that a special case is needed for e.message.
In addition, you can't match on the detail of an exception at all which means you can't differentiate between two similar exceptions.
I'm not quite sure what the best solution is here. I'd be tempted to change both calls of reFindNoCase( arguments.regex, e.message ) to ( reFindNoCase( arguments.regex, e.message ) || reFindNoCase( arguments.regex, e.detail ) ). That would solve the immediate problem insofar as you could then match on detail OR message.
Longer term, adding support for matching detail separately and special-casing for message / detail being empty strings would probably be a better solution.
FWIW, I made the simple change locally of testing regex against message or detail and that's working nicely for me.
Sorry. Trying to catch up from vacation. Coming back is more stressful than
Ortus Solutions, Corp
ColdBox Platform: http://www.coldbox.org
ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox |
twitter.com/lmajano | twitter.com/gocontentbox
I am going with Sean's suggestion at this point where it should match either the message or detail. I also changed it to match no case thanks to Adam's investigation.
Cool. Did you add .withDetail() as well? If not, should I raise a new ticket?
No, you can raise a ticket so we can brainstorm on it. I have not really had a real-life scenario for this, using the toThrow() as is with the addition has good coverage. But yea, go for it.