#10 new
James Mead

[#17695] RR style proxies

Reported by James Mead | January 1st, 2009 @ 06:53 PM

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.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

A mocking & stubbing library for Ruby.

* <a href="http://github.com/floehopper/mocha">GitHub repository</a>
* <a href="http://mocha.rubyforge.org">Documentation</a>
* <a href="http://groups.google.com/group/mocha-developer">Mailing List</a>

Pages