[rspec-users] Stubbing out method for all instances

David Smalley david.smalley.lists at googlemail.com
Tue Mar 27 06:34:55 EDT 2007


On 27 Mar 2007, at 11:19, aslak hellesoy wrote:

>
> What's Test::Unit mocks?

Ah sorry, by which I mean the /test/mocks/<env>/mocked_code.rb     
setup in a default Rails skeleton - it lets you drop a replacement  
for a method that appears higher up in the search path and allows you  
to completely over-ride a method.

>
>> and just replace the encoded? instance method for all objects that
>> might use it to just return true.
>>
>> Any ideas?
>>
>
> You can submit a feature request - ideally with a failing spec to
> illustrate what you want.

After a bit of digging around it looks like David (Chelimsky) has  
already submitted such a feature request

https://rubyforge.org/tracker/index.php? 
func=detail&aid=6791&group_id=797&atid=3152 - looks a lot like what I  
want.

Consider it similar to the syntax offered by mocha

e.g.
Order.any_instance.stubs(:shipped_on).returns(nil)

I think it would be a very helpful addition to Rspec stub/mock  
framework - I'd be interested in helping to implement it but I fear I  
don't know enough about how mocking works. I'll dig into mocha and  
rspec code but if any of the Rspec developers want to take the lead  
that would be great!

Cheers,

David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070327/9cb16f49/attachment-0001.html 


More information about the rspec-users mailing list