Got at the bottom of it - as suggested,
object.stub(:method).with(:value).and_return(:ret) multiple times with
different :value [s], though it causes calls to :method to fail unless
it has one the :value [s] passed.
Thanks!
Saverio
Saverio Miroddi wrote:
> Thanks for the help - I'm
aul Hinze wrote:
> On Sun, Jan 24, 2010 at 5:10 PM, Saverio Miroddi
> wrote:
>> class MyController < ...
>> �def show
>> � �m = MyModel.find( params[ :id ] )
>> � �mp = m.my_parent
>>
>> � �...@m_value = m.value
>> � �...@mp_value = mp.value
>
David Chelimsky wrote:
> It'd be much easier to help you if you could provide an example more
> representative of what you are actually trying to accomplish.
So, here it is (note: this is NOT representative of a properly
engineered behavior):
class MyModel
def my_parent
self.find( my_paren
David Chelimsky wrote:
>>> MyModel.stub(:find).with(42).and_return(myModel)
>> Didn't work as expected - I'll do a bit of research and post again.
> What is expected? What are you trying to accomplish?
Example in horror-code:
##
class MyController
Tom Stuart wrote:
> On 10 Nov 2009, at 14:08, Saverio Miroddi wrote:
>> Is there a clean/simple way of stubbing the activerecord find() for a
>> single instance?
>
> MyModel.stub(:find).with(42).and_return(myModel)
Didn't work as expected - I'll do a bit of rese
Is there a clean/simple way of stubbing the activerecord find() for a
single instance?
As usual pattern, I see something like
myModel = MyModel.new(...)
MyModel.stub( :find ).and_return( myModel )
which can give problems in case we want to find other instances.
???
Saverio
--
Posted via http:/