On Thu, Aug 25, 2011 at 09:09:36PM -0700, Scott Harvey wrote: > Gareth, > > The paid named_scope in the example is on the LineItem model so stubbing > that out would not be stubbing out the object under test. > > The test that checks that the paid named_scope works will be in the LineItem > spec folder so I'm happy to stub the named_scope out if there is a nice way > to do that.
It looks like stub_chain might help: http://apidock.com/rspec/Spec/Mocks/Methods/stub_chain I.e. (untested): mock_line_item = mock("line_item") mock_line_item.stub(:cost).and_return(10) Order.stub_chain(:line_items, :paid).and_return([mock_line_item]) Still feels wrong though ... Malc -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
