[rspec-users] change() vs change{}

David Chelimsky dchelimsky at gmail.com
Wed Oct 24 16:29:38 UTC 2012


On Wed, Oct 24, 2012 at 12:26 PM, Kevin McCaughey <lists at ruby-forum.com> wrote:
> Hi,
>
> I am doing the rails tutorial and there is a line:
>
> expect { click_button submit }.not_to change(User, :count)
>
> When I looked up the rspec docs and book too, I found:
>
> change {} documentation (using curly brackets).

Not sure which docs you looked at, but both () and {} are supported,
as described in rspec's rdoc:
http://rubydoc.info/gems/rspec-expectations/RSpec/Matchers#change-instance_method

>
> Could someone tell me what the difference is, and if I use a block for
> the above example, what would it look like?
>
> I am very confused about why there are two versions and can't seem to
> get examples for the block {} version to see it's proper usage.
>
> Many thanks!
>
> Kevin McCaughey
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list