Re: [rspec-users] Stub activerecord find given instance?

2010-02-08 Thread Saverio Miroddi
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

Re: [rspec-users] Stub activerecord find given instance?

2010-02-05 Thread Saverio Miroddi
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 >

Re: [rspec-users] Stub activerecord find given instance?

2010-01-24 Thread Saverio Miroddi
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

Re: [rspec-users] Stub activerecord find given instance?

2010-01-12 Thread Saverio Miroddi
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

Re: [rspec-users] Stub activerecord find given instance?

2009-12-12 Thread Saverio Miroddi
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

[rspec-users] Stub activerecord find given instance?

2009-11-10 Thread Saverio Miroddi
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:/