[rspec-users] Setting expections on chained calls
rob at stardotstar.com
Wed Nov 2 14:01:30 EDT 2011
I'm pretty sure this has probably been discussed before.
I'm using couchdb (couchrest_model)
When speccing my controller i want to set expectations that im calling my couch views correctly.
The query interface has recently been updated to work very similar to ARel
This means i have to rewrite some of my specs.
Exam.by_created_at_and_not_archived(:start_key => [@exam.created_at], :endkey => ['0'],:limit => 2)
I set an expectation on that easily like so:
with(:startkey => [@exam1.created_at],:endkey => ['0'],:limit => 2).
and_return([@exam1, at exam2])
However the new api i doesn't seem that easy to work with:
I could use stub_chain, but that doesn't allow me to check the params being passes to the calls other than the last.
I could also create a wrapper method on my Exam model that is called from the controller with hash params,
however that just shifts the problem, I then have to check the expections in the model spec instead.
Suggestions on how best to go about that would be appreciated.
More information about the rspec-users