[rspec-users] Another attempt for a succinct model validation DSL

Joseph Method tristil at gmail.com
Fri Jun 1 14:47:04 EDT 2007

How about this?


The strategy is to check if the string argument is :validations (so
this would become reserved). If it is, then include ModelValidations.
'it' without the block returns an object that contains a should
method. The block it opens is related to but different from the one
that 'it' opens.

given doesn't seem strictly necessary, since we know what's being
described, but it reads well and is explicit.

> I think that I still prefer dedicating the entire behavior to
> validation of a particular field (that's what I do in my current specs
> anyway, albeit with far more lines of code).

I'm sure we won't be able to agree on this, but it seems like overkill
to me. What if in this proposal there was an option for
:validation_of_password, etc.?

> I don't think it would be right to have the behavior method "it"
> running double-duty (it is already used to create the examples).
> Also, I don't really see much benefit of "it.should_validate" over
> "it_should_validate".  But I do like the idea of the example method
> "it" getting the results of the "given", and that should be easy (I
> think).

Yeah, what's described here might be too evil. In its defense, though,
the new 1.0 syntax seems to emphasize subject.should predicate over
subject.should_predicate, which is what I've tried to preserve.

> --
> Nick

-J. Method

More information about the rspec-users mailing list