[rspec-users] authentication mocks

Jerry West jerry.west at ntlworld.com
Wed May 30 09:22:07 EDT 2007

Hi Jonathan,

You should be able to stub the routines a controller uses to check if a 
user is logged in, which will allow your controllers to function without 
actually requiring you to post login details. Something like 
'controller.stub!(:logged_in?).and_return(true)' should suffice.  Or you 
could stub the before_filter method itself.   Check to see what your 
code calls behind the scenes.  You may find you need to stub routines in 
the authentication module depending on what you want to spec (e.g. 
action on failing login, action on incorrect authorization, logging in 
via cookie, etc). 


Jonathan Linowes wrote:
> hi
> I'm using restful_authentication
> and have controller specs working using users fixtures (and login_as)
> however i've been trying for hours without success to do it without  
> fixtures, using mocks and stubs instead.
> anyone here done this? got code?
> :)
> thanks
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list