[rspec-users] mock assertions on block parameters
matt at mattwynne.net
Mon Jun 7 12:15:59 EDT 2010
On 7 Jun 2010, at 16:52, Ben Butler-Cole wrote:
> On 7 June 2010 16:34, Matt Wynne <matt at mattwynne.net> wrote:
> I'm still not quite clear what you're trying to achieve. Do you want to assert that a specific block is passed to the collaborator, or do you want to assert that any old block with a particular behaviour is passed to the collaborator?
> If it's the former, you can test it by creating a test double for the block, and asserting that it's passed to the collaborator
> The later. The block gets created by the code under test, so I can't create a double for it.
Aha OK. I don't know how to do that using RSpec's mocking framework. I'd probably just build my own test double for the collaborator, giving it some simple behaviour to test the block. Something like this:
There might be a way to do this using custom matchers but I don't know how to do it myself. Hopefully someone else will chime in if there is.
> rspec-users mailing list
> rspec-users at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users