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

nicholas a. evans nick at ekenosen.net
Mon Jun 4 14:03:21 EDT 2007

On 6/4/07, Joseph Method <tristil at gmail.com> wrote:
> I think Nicholas has moved on to a different approach, but I agree
> that this approach deserves looking at again,

Not yet... I'm just jumping about from one to the other, trying each
on for size.  ;-)

After all of this typing, I wanted to get *something* implemented
though.  And going with a normal rspec matcher is really the correct
starting point.  It's useful even if/when we have an additional
shortcut syntax, it should be used to implement the shortcut syntax,
and there seemed to be some level of consensus finally settling on
what it might look like.

I wrote this up several hours ago, but never posted it:

It looks a lot like your example (and Martin's, which prompted me to
write it).  I'm still avoiding the dot and space notation, because
that relies on code that works in the example binding, but I don't
want to mess with in the behavior binding.  I'm also avoiding sending
a variable into the block because it feels to me like extra verbosity
with no extra readability or useful flexibility.  I haven't decided
whether I like "should_accept" more than "it_should_accept"... the
saved three characters are probably not be worth the delta from the
rspec way.

> in part because it
> avoids the opinion about whether a single validation should be a
> context or a specification.

That is a good point.

> But lo, rspecishness can be preserved:
> http://pastie.caboo.se/67649
> IMO, not doing this makes it look declarative and unit/test-y. It's
> the difference between
> obey!(:me)
> and
> you.should obey(:me)

I strongly agree.  I will gladly sacrifice a little bit of concision
in order to stay in the rspec readability/behavior/specification
paradigm.  But I do want to (as much as is possible) remain in The
Rspec Way with as little verbosity and noise distracting from the
examples as is reasonable.  David, Aslak, oh wise guardians and
mentors of The Rspec Way, what do you think of my latest pastie?
http://pastie.caboo.se/67605  :-)


More information about the rspec-users mailing list