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

aslak hellesoy aslak.hellesoy at gmail.com
Fri Jun 1 18:59:23 EDT 2007


On 6/2/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 6/1/07, Joseph Method <tristil at gmail.com> wrote:
> > How about this?
> >
> > http://pastie.caboo.se/66977
> >
> > 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.
>
> Well now we're getting much simpler. Instead of a whole new structure,
> why not just use a custom matcher?
>
> http://pastie.caboo.se/67069
>

Brilliant!

Aslak

> >
> > > --
> > > Nick
> >
> > --
> > -J. Method
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list