search for: stops_mocking

Displaying 2 results from an estimated 2 matches for "stops_mocking".

2007 Aug 08
1
Mocking Time, delegating to original object
In my Unit tests, I run into the all-too-common problem of Time.expects(:now) being called by Benchmark before the method is unmocked. Instead of messing around with the teardown order, I decided to modify the Expectation with a new method, .stops_mocking. Here are the changes I use, including a few monkey patches to push relevant objects down to where I want them, all wrapped up in a big ugly file. module Mocha class Mock def expects(method_name_or_hash, backtrace = nil, stub_method = nil) @stub_method = stub_method if method_n...
2008 Jan 02
2
Proxies
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, the...