[rspec-users] step definitons to check login
apremdas at gmail.com
Tue Dec 16 18:47:27 EST 2008
Doing this for Restful-Authentication I add the following in
# Make visible for testing
ApplicationController.send(:public, :logged_in?, :current_user,
Hopefully something similar will work with Authlogic
2008/12/16 James Byrne <lists at ruby-forum.com>
> I am working with the authlogic gem and trying to create a simple login
> test from cucumber features. The feature statement is:
> Given the user is not logged in
> The step definition for this is confounding me. In the
> application_controller the authlogic tutorial recommends the following:
> def require_user
> unless current_user
> flash[:notice] = "You must sign in to access this page"
> redirect_to new_user_session_url
> return false
> def require_no_user
> if current_user
> flash[:notice] = "You must be logged out to access this page"
> redirect_to account_url
> return false
> As these are private methods they are not directly accessible from the
> step definitions and I am at a loss as to how to proceed. I could
> augment the application controller with a public user_authenticated
> def user_authenticated
> return true if current_user
> But it seems wrong to alter the application code for no other purpose
> than to ease testing. Is there another approach that I should be using?
> Posted via http://www.ruby-forum.com/.
> rspec-users mailing list
> rspec-users at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users