[mocha-developer] Proxies

Duncan Beevers duncanbeevers at gmail.com
Fri Feb 1 15:05:26 EST 2008


Awesome.  Thanks James.

On Feb 1, 2008 5:03 AM, James Mead <jamesmead44 at gmail.com> wrote:
> 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.
>
> --
> James.
> http://blog.floehopper.org
> http://tumble.floehopper.org
>
> [1]
> http://rubyforge.org/tracker/index.php?func=detail&aid=17695&group_id=1917&atid=7480
>
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>


More information about the mocha-developer mailing list