[rspec-users] step definitons to check login

David Chelimsky dchelimsky at gmail.com
Wed Dec 17 11:56:48 EST 2008

On Wed, Dec 17, 2008 at 9:23 AM, James Byrne <lists at ruby-forum.com> wrote:
> Pat Maddox wrote:
>> James Byrne <lists at ruby-forum.com> writes:
>> I think Zach's point was that you can tell that someone is logged in if
>> you see a "edit your profile" link somewhere, and they're not logged in
>> if you see a "log in" link on the page.  Yes, of course it's useful to
>> know whether someone is authenticated or not...but you can test that
>> through properties of your own app, rather than digging under the hood
>> and calling the auth system directly.
> That is what I gathered from the "visits login_path" statement in
> David's example.  Still, I am interested in finding out what other ways
> are possible to test for session authentication status and how implement
> them, if only to assure myself that they are not the way I want to do
> this.  I have yet to unload a lot of baggage retained from previous
> experience.

You're a bit restricted in cucumber out of the box, because for rails,
cucumber wraps ActionController::Integration::Session, which goes
through routing. You don't have controller objects readily available.

You have two options if you want to get at internals here (which
should really be your last resort):

1. write a new World for cucumber that wraps
ActionController::TestCase instead of
ActionController::Integration::Session. You'd have to figure out a way
to have that World loaded for some scenarios and the other loaded for

2. use rspec-rails for more granular inspection. In an rspec
controller spec, you have access to the controller object.


> I am also trying to gain a comfort level with the authlogic gem.  That
> desire is in part driving this quest.
> --
> Posted via http://www.ruby-forum.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