[rspec-users] How to return a value passed by ref to a method

Scott Taylor scott at railsnewbie.com
Sun Feb 8 15:21:24 EST 2009

Remi Gagnon wrote:
> Hi,
> I have a recursive method and I want to mock a var passed by ref.  
> Object.should_receive(:my_method).and_return"by_ref"(@value)
Often a way to spec a recursive function is to alias it, and have the 
recursive call call the alias.  So if you want to check the recursion, 
you could do something like this (in a lispy-type ruby):



More information about the rspec-users mailing list