I want to call a named_scope that will only return one record, but the named_scope returns an array, that’s not a big deal as I can just chain it with .first:
Model.named_scope(param).first
and this works, what I am struggling with is how to stub the chained call. Does anyone have a reference or an answer on how I would go about achieving this with Rspec mocking?
I figured something out.
which allows me to call my controller:
It works, but is there a better solution?
EDIT:
The release of rspec 1.2.6 allows us to use stub_chain meaning it can now be:
This was top of my head, as always check the api for specifics 🙂