Date: 2008-02-01 13:01 Opener: James Mead
Posted on behalf of Duncan Beevers http://rubyforge.org/users/dunca...
from post on mailing list
http://rubyforge.org/pipermail/m...
I really like the idea of Mock Proxies as explained in Brian
Takita's post here:
http://pivots.pivotallabs.com/us...
I posted to this list eariler with an incomplete implementation
of stops_mocking in the thread "Mocking Time,
delegating to original object."
http://rubyforge.org/pipermail/m... 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.