On Thu, Mar 6, 2008 at 7:23 AM, Pat Maddox <[EMAIL PROTECTED]> wrote: > On Thu, Mar 6, 2008 at 7:12 AM, Bastien <[EMAIL PROTECTED]> wrote: > > Thanks David, this works just fine. I would rather do some stubbing > > there if it's possible though. I tried : > > > > ApplicationController.stub! > > (:user_authentication_required).and_return(true) > > try > controller.stub!(....)
Perhaps I should explain why this is. stub! adds a stubbed method to an object. In Ruby, classes are objects as well, so what you've done is to stub a method on the ApplicationController class object itself - effectively creating a class method. When you override the method yourself, you're overriding an instance method. So in order to stub out the method for a request, you want to stub it on the _instance_ of the controller being used in the test. That controller instance is made available to you through a method named "controller". Pat _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
