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 offset
. Unfortunately the code below does not work. It seems it is not possible to mix should_receive and stub_chain. How could I solve this? I am using RSpec 2.
MyModel.should_receive(:offset).with(0).stub_chain(:tag_counts, :offset, :limit, :order).and_return([]) # does not work!
The code I am trying to test:
tags = taggable.tag_counts.offset(page-1).limit(per_page).where(*where_clause).order("count DESC")
Update
I also posted the question on the RSpec Google Group were David (the creator of RSpec) answered it (thanks David): http://groups.google.com/group/rspec/browse_thread/thread/6b8394836d2390b0?hl=en