On 12/02/2009, at 2:59 PM, David C. wrote:
@form.should have(1).error_on :file
validate, but that would pit the onus on users to validate
explicitly (not to mention the upgrade burden).
I think it comes down to how much work you expect to have to do
yourself, versus how much “magic” you expect will, or would like to,
happen in the background.
It never crossed my mind that a matcher would call #valid? . My
impression of matchers was that they simply reported on whether or not
an object had a specific setting/property. I figured the matcher
simply checked the AR model object for the specified error, regardless
of whether or not I’d called #valid? .
Personally, I don’t think that matchers should be modifying the
objects that they check. In my mind, a matcher is like an overseer: it
reads and reports, but doesn’t tinker.
Another reason that I think matchers shouldn’t call #valid? is because
of the inconsistencies doing so can produce between spec examples.
Examples that use have(X).errors_on won’t have an explicit call to
#valid? , while examples that don’t use that matcher, but need #valid?
to be called, will have an explicit called to #valid? .
That’s my perspective on the matter. However, I’m not necessarily
advocating that the current behaviour change. Others have said that
they find it logical that #valid? is called for them. Who’s to say