RSpecでArelのメソッドチェインをスタブにする
テストでメソッドチャインできるメソッドをスタブにする。
describe BlogsController do before do(:all) u = User.new User.stub_chain(:where, :limit, :order).and_return(u) end end
こういう書き方も出来る
describe BlogsController do before do(:all) u = User.new User.stub_chain([:where, :limit, :order] => u) end end