Hello, folks.
In order to support the syntax:
myException should have (message ("fubar"))
the HaveWord class should have an apply method taking ResultOfMessageWordApplication, much as it does for the size and length applications.
Having said that, I think we could actually get rid of all of those special-case apply functions on HaveWord, and instead put implicit conversions from the ResultOf*WordApplication classes to HavePropertyMatcher on the companion objects for ResultOf*WordApplication. This would allow syntax like:
myException should have (message ("fubar"), 'cause (myCause))
One possible implementation would be:
implicit def resultOfMessageWordApplication2HavePropertyMatcher[T : scala.reflect.ClassTag : Messaging](romwa: ResultOfMessageWordApplication): HavePropertyMatcher[T, String] = romwa(of[T])
Given that you have a non-implicit conversion on the ResultOf*WordApplication classes already, I suspect I'm missing some good reason not to do the conversion implicitly... but honestly, I don't see it. Could you explain the reason to require the explicit conversion?
- Alex
P.S. My actual use case for this is a class with a field called "message" along with a lot of other fields. I was stumped for a while, trying to figure out why I couldn't define and use a HavePropertyMatcher named "message" like I did with all the other fields (to give compile-time errors in the tests for a typo on the field name)... until i discovered that "message" is a special-case property with the enablers, etc. The current implementation seems overly complex just to allow use without parens.