[mocha-developer] Testing event driven Socket classes

hemant gethemant at gmail.com
Sun Dec 17 14:30:49 EST 2006

On 12/16/06, James Mead <jamesmead44 at gmail.com> wrote:
> I think you have misunderstood what Mocha is doing for you. When you
> use expects() or stubs() on a real object, Mocha temporarily replaces
> the named method with a new implementation which can verify the method
> was called in the way you expected and/or return the specified result.
> The original implementation is not invoked.
> So when you have...
>   @server.expects(:send_to_client).at_least_once
> send_to_client is indeed being called - try commenting out the call to
> send_to_client in dispatch_request and you will see a Mocha
> expectation error - but the original implementation of send_to_client
> is not invoked.
> And when you have...
>   @server.expects(:dispatch_request).at_least_once
>   @server.expects(:send_to_client).at_least_once
> send_to_client is never called, because the original implementation of
> dispatch_request is not invoked.

Yup...thanks James for explaining it for me. I get it now.

There was only one Road; that it was like a great river: its springs
were at every doorstep, and every path was its tributary.

More information about the mocha-developer mailing list