« Return to Thread: How do I mock out the before :login_required method?

Re: How do I mock out the before :login_required method?

by Max Williams :: Rate this Message:

Reply to Author | View in Thread

I'm having a similar problem - my application controller has the UserSystem module included, and that's where the login_required method lives.  In a spec for another controller, which has before_filter :login_required, i'm trying to stub the login_required method to just return true, but i think my problem is that i'm calling it on the class instead of an instance of ApplicationController:

ApplicationController.stub!("login_required").and_return(true)

Looking at my log file, the :login_required filter is still failing, so it looks like my stub has missed its target.  How do i call it on the actually controller?  I've seen in another thread that "I can get the controller from my specs" but i don't know exactly what's meant by that.

 « Return to Thread: How do I mock out the before :login_required method?