I am trying to test if in a method calling chain one of the methods get a specific parameter. In the below code for example MyModel must receive the parameter 0 for the method <
This is an example what I do in one of my specs now. It's a bit unhandy (cause of the many lines), but it works:
SearchPaginationModel.stub(:tag_counts) { SearchPaginationModel }
SearchPaginationModel.should_receive(:offset).with(0) { SearchPaginationModel }
SearchPaginationModel.stub_chain(:limit, :where, :order) { [] }
SearchPaginationModel.stub_chain(:tag_counts, :where, :count).and_return(1)
SearchPaginationModel.search_tags(:page => "1")
This for example tests in SearchPaginationModel.tag_counts.offset(0).limit(X).where(X).order(X)
that really offset
0 is set.