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
Hi Michael - Here is how I am doing it on a current project. def mock_user_authentication(allow_user_to_pass=true) controller.stub!(:login_required).and_return(allow_user_to_pass) end The controller is available in your controller specs. 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-- Graeme Nelson Developer PLANET ARGON, LLC Ruby on Rails Development, Consulting & Hosting www.planetargon.com +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax] -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070405/3dc5c751/attachment-0001.html
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
Thanks so much. Funny that you responded because I saw your post about testing controllers and your mention of mock_user_authentication, but no implementation for it when I did a search. I tried to contact you but couldn''t find a contact address. Anyway, thanks so much. I''ll give that a shot. Michael On Apr 5, 2007, at 11:07 PM, Graeme Nelson wrote:> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users