[rspec-users] Mocking Authentication

Graeme Nelson graeme.nelson at gmail.com
Thu Apr 5 23:07:05 EDT 2007


Hi Michael -

I tried to reply from my work email and it bounced. oops.

This is what I am doing on a current project:

   def mock_user_authentication(allow_user_to_pass=true)
     controller.stub!(:login_required).and_return(allow_user_to_pass)
   end

You get the controller object with your controller specs.

I am sure there are other ways of doing this, but I found this to be  
pretty clean.

Thanks
Graeme Nelson

On Apr 5, 2007, at 6:30 PM, Michael Trier wrote:

> Is anyone using Restful Authentication?  If so, how are you mocking
> the login for your controllers?  I'm having trouble with it and would
> love an example of someone's login.  I'm sure I'm missing something
> simple.
>
> Michael
> railsconsulting.com
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list