Let's say we have some piece of code like so:
def index
@posts = Post.where(:status => ACTIVE)
if params[:s]
@posts = Post.where("title like ?", "%#{params[:s]}%").order("title asc")
else
@posts = Post.limit(20).order("date desc")
end
end
When specing this action we could either write a stub chain for every example but this way it restrains us a lot if we want to focus somewhere else.
What's the best way to stub a complex Arel query for RSpec when you don't know the order or how many of the methods will be called?
NOTE: I was looking at Stubbing Chained Queries in Rails 3 and Rspec and what I think I want is something like stub_chain_with_indifferent_order(:where, :order, :limit)
.