[rspec-devel] [rspec-users] Coming Soon...

Brandon Keepers bkeepers at gmail.com
Fri Feb 2 09:31:33 EST 2007

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

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.


More information about the rspec-devel mailing list