[rspec-users] Testing misc methods in ApplicationController

Nick Hoffman nick at deadorange.com
Fri Feb 13 21:19:04 EST 2009

On 13/02/2009, at 7:26 PM, Fernando Perez wrote:
> How do you spec protected controller methods such as before_filters  
> and
> helpers that with the params and session hashes?
> I cannot call controller.my_method if my_method is protected.
>> Try this:
>> controller.andreplace("foo and bar").should eql("+foo +bar")

Hey Fernando. As Mark said, the idea behind BDD is to spec the  
behaviour of your controller, rather than each specific method. So  
write specs for all of the different behaviours that your controller  
can exhibit. This will result in your protected and private methods  
being called.


More information about the rspec-users mailing list