On Feb 13, 2008 6:52 AM, Max Williams <
toastkid.williams@...> wrote:
>
> 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.
There is a method named controller that you can call to access the
controller from within the spec:
controller.stub!(:whatever ....)
HTH,
David
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users