Posted at

rspecで引数を持つ関数をstub_chainする方法

More than 5 years have passed since last update.

この関数をstubするには

Payment.order(:updated_at).where(:paid => true).count

こう書く

Payment.stub_chain(:order, :where, :count).with(:updated_at).with(:paid => true).with().and_return(10)


参考

http://stackoverflow.com/questions/8003445/rspec-stub-chains-with-arguments