[rspec-users] Controller spec: testing that scope is set

Michael Schuerig michael at schuerig.de
Sun Apr 19 21:57:19 EDT 2009

On Monday 20 April 2009, Zach Dennis wrote:
> In your original post you asked:
>    "How would I go about adding support a scope expectation?"
> Given the code you've shown it is not clear exactly what you are
> expecting. Do you just want to be able to expect that you call
> model_class.send(:with_scope) with the appropriate arguments?

I'd rather check that a particular scope is in effect for a call to 
#find. Just as I said. ;-)

The reason is that I don't want to encumber my controller specs with how 
or where the currently effective scope was set. It might have been 
multiple nested calls to with_scope or named scopes. In my current code 
this is not the case, but that's an implementation detail.

In the specs for the code that does set the scope, an expectation on the 
call to with_scope is the right thing. But that's an entirely different 
spec at a lower level ob abstraction.


Michael Schuerig
mailto:michael at schuerig.de

More information about the rspec-users mailing list