Stub activerecord find given instance?

View: New views
2 Messages — Rating Filter:   Alert me  

Stub activerecord find given instance?

by Roger Pack-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Stub activerecord find given instance?

by Tom Stuart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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)
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users