Hey Doug,
That won''t work because of how Ruby handles the equality of lambdas/
procs.
From my experience there are 2 approaches.
1) Test both the "call" and the block together. So instead of mocking
Util, mock SfProperty.
or
2) Store the lambda somewhere (like a Class variable). Test the lambda
separately, and test the "call" separately, but treat the lambda as a
black box. (though I''m sure you could do something funky with
redefining the Class variable within the test, and asserting that the
redefinition got passed in the "call" method).
Testing passed lambdas/procs can be tricky because you''re testing the
behavior of something that _defines behavior_ and passes it to
something else.
On Jul 7, 2009, at 7:27 AM, doug livesey wrote:
> Hi -- can I specify the block that should be called with a method?
> Sort of like this:
>
> it "should bulk update the properties_params in groups of 50"
do
> block = lambda do |params|
> SfProperty.put( :bulk_update, :sf_properties => params )
> end
>
>
> Util.should_receive( :do_to_in_groups_of ).with( @properties_params,
> 50, &block )
>
> do_call
> end
>
> Or am I dreaming?
> Cheers,
> Doug.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
--
Zach Moazeni
http://simplechatter.com