On Sat, May 10, 2008 at 9:40 AM, Craig Demyanovich
<[EMAIL PROTECTED]> wrote:
> A syntax note from the RSpec docs: "blocks passed to should change and
> should_not change must use the {} form (do/end is not supported)."
>
> http://rspec.info/rdoc/classes/Spec/Matchers.html#M000386

But, I'm pretty sure that this is talking about a block which is
passed as an argument to should_change/should_not_change as in this
example from the docs:

string = "string"
  lambda {
    string.reverse
  }.should change { string }.from("string").to("gnirts")


as opposed to:

string = "string"
  lambda {
    string.reverse
  }.should change do
       string
  end.from("string").to("gnirts")

This is because do/end binds less tightly than {} so that in the first
(working case) the block is passed to the change method, while in the
second one it gets passed to the should method instead.

On the other hand:

string = "string"
  lambda do
    string.reverse
  end.should change { string }.from("string").to("gnirts")

should work, although I prefer the {} syntax in this case.
-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to