Friday, 19 April 2013

rails stub chained for rails activerecord::relations

For whenever you have a multiple clauses on a model like:

Product.where(condition).includes(tables)

you can stub this using this

Product.stub_chain(:where, :includes).and_return([what you want])

easy :)

http://apidock.com/rspec/Spec/Mocks/Methods/stub_chain

0 comments:

Post a Comment