[mocha-developer] Proxies

James Mead jamesmead44 at gmail.com
Fri Feb 1 08:03:46 EST 2008

On 02/01/2008, Duncan Beevers <duncanbeevers at gmail.com> wrote:
> I really like the idea of Mock Proxies as explained in Brian Takita's post
> here:
> http://pivots.pivotallabs.com/users/brian/blog/articles/352-introducing-rr
> I posted to this list eariler with an incomplete implementation of
> .stops_mocking in the thread "Mocking Time, delegating to original
> object."  The Mock Proxy pattern would make this simpler.
> Proxy(User).expects(:find).with(99) # Sets expectation, forwards
> method invocation to original class
> User.expects(:find).with(99).returns(nil).then.proxies # Canned
> response, then forwards successive invocations to original class.
> Most of this is just my desire to be lazy and not actually have to
> unit-test *trivial* methods explicitly.  I also like the idea of using
> the Mock Proxy to exercise the behavior of simple private instance
> methods of my class which are kind of a pain to test currently, which
> leads to my not making anything private.

I've taken the liberty of adding this as a feature request [1] on rubyforge.



More information about the mocha-developer mailing list