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

nicholas a. evans nick at ekenosen.net
Fri Jun 1 13:02:24 EDT 2007

On 6/1/07, Joseph Method <tristil at gmail.com> wrote:
> What about 'this' as a reserved name for what's given?

I thought about trying something like that, and thus try to get back
to the "normal" rspec syntax but it seems to me that "it" better
fulfills that role.

Here's my thought on a syntax like that: http://pastie.caboo.se/66937

How close does that compare to what you were thinking of, Joseph?

(I prefer to use "specify" rather than "it", when I'm using the
generated example string.)

Now that I look at it, I actually think this is a rather nice syntax.
But it's a lot more verbose than I'd like...  perhaps
"it_should_reject(foo)" could simply be shorthand for "specify {
it.should reject(foo) }".  This also makes it obvious how to override
the generated example string.

Thoughts?  Is it an evil or difficult thing to repurpose "it" to my
own dubious ends inside the examples?  I really like the idea of "it"
simply returning the result of the block that was previously passed to


> given { User.new }
> this.should_reject (nil)
> given { User.new(:name => 'Bob' }
> this.should_reject(nil)

More information about the rspec-users mailing list