[rspec-users] Coming Soon...

David Chelimsky dchelimsky at gmail.com
Fri Feb 2 09:51:23 EST 2007


On 2/2/07, Brandon Keepers <bkeepers at gmail.com> wrote:
> David & crew,
>
> On Feb 2, 2007, at 5:53 AM, David Chelimsky wrote:
>
> > == What's up w/ the parens and {} blocks?
> >
> > Parens: When you do this:
> >
> >   a.b c d
> >
> > ... Ruby gives you the all familiar:
> >
> >   "warning: parenthesize argument(s) for future version"
> >
> > If you can live w/ that, then have at it w/o the parens.
> >
> > Curly braces: This has to do w/ precedence. do/end has a lower
> > precedence than {}, which means that in this expression:
> >
> >   target.should satisfy do
> >   end
> >
> > ... the block will be passed to #should instead of #satisfy. We need
> > the blocks to be passed to the matcher (#satisfy in this example), so
> > curly braces are required. This will be enforced by RSpec. When
> > #should or #should_not receive a block, the spec will fail with a
> > warning telling you to use {} instead of do/end. So you won't have the
> > opportunity to simply forget.
>
> You could also do:
>
> target.should(satisfy do
>    # block here
> end)
>
> It's not necessarily any cleaner, but it works.
>
> Good work!  I like the new syntax and am looking forward to being
> able to write my own expectations.

Cool. Let us know as you do, especially if you come up w/ some that
are more general purpose.

Thanks,
David

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


More information about the rspec-users mailing list