[rspec-users] Spec the Application Controller application.rb
pergesu at gmail.com
Wed Apr 23 02:36:33 EDT 2008
On Tue, Apr 22, 2008 at 11:19 PM, Andy Croll <lists at ruby-forum.com> wrote:
> Pat Maddox wrote:
> > You can define a controller method on the fly in order to test this
> > out. I just did a quick experiment to demonstrate it...obviously
> > modify to suit your needs.
> Thanks Pat.
> I think I'm confusing two issues.
> 1) How to test before filters for something like authentication
> 2) How to test functions provided in the application controller
> I'm not putting the before filter in the application.rb, I'm likely to
> be using it to protect various actions in the app.
You can still use the technique that I showed, you would just call
before_filter in the fake controller. That would allow you to specify
and implement the filter in isolation.
> Is there a way to to call methods directly within the application.rb,
> spec them there and then sub for functionality in the other
No to the first part, unfortunately. Rails' controller design isn't
As far as using them in other controllers, you can just use the real
filter implementation if you want, or stub them if you prefer.
More information about the rspec-users