On Feb 13, 2008 6:52 AM, Max Williams <[EMAIL PROTECTED]> 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 > -- > View this message in context: > http://www.nabble.com/How-do-I-mock-out-the-before-%3Alogin_required-method--tp15448454p15456464.html > Sent from the rspec-users mailing list archive at Nabble.com. > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users