[mocha-developer] Stubbing yielding methods

James Mead jamesmead44 at gmail.com
Wed Jan 2 10:19:15 EST 2008

On 21/09/2007, John Pywtorak <jpywtora at calpoly.edu> wrote:
> I would weigh in that something like yields is needed and possibly the
> suggested patches as well.  I do agree that it seems to work the wrong
> way.  I went and looked at how I had used yields and found what I think
> validates my assertion above.
> Take for example: IO.open, IO.popen, etc.
> puts IO.popen("ls", "r") { |pipe| pipe.read }
> OK, so this example is contrived; However, I do think it points out some
> important things.  It is desirable to have expectations of both the call
> to popen, or the block, or both; However, rather than yield as a
> modifier to the methods expectations, separate the block's expectations,
> and return values out.  Basically rather than one statement combining
> the two, require two statements.

Thanks for your interest, although I'm not sure I follow your
reasoning. Could you give examples of actual tests and code under test
and explain either how you use the existing features of Mocha or how
you'd like it to work?


More information about the mocha-developer mailing list