On 7 Jun 2010, at 15:13, Ben Butler-Cole wrote: > Hello. > > I'm trying to use RSpec's mocks to describe code which passes a block to a > collaborator. I want to write an assertion against the value returned by the > block. I can't find any explicit support for this in RSpec, but perhaps I > have missed something. > > I have come up with a hack which almost does what I want, by hijacking the > and_return block (see http://gist.github.com/428624). But this doesn't work > for more complex cases where there are multiple calls in the code under test > which pass different blocks. > > Is there any way to make assertions like this? From looking at the code, I > think it would take some significant changes to support this; but it doesn't > seem to be a terribly esoteric use case. > > Thanks for any suggestions.
Have you seen and_yield? I can't quite get my head around what you're trying to do, but it might help anyway: http://rspec.info/documentation/mocks/message_expectations.html cheers, Matt > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users