Capybara/Steak/Rspec: Is session maintained between calls to visit()?

427 views
Skip to first unread message

David Kahn

unread,
Dec 16, 2010, 4:17:09 PM12/16/10
to ste...@googlegroups.com
I have this spec using Steak where I am testing that if a user has a session (logged in), if they go to the login page they are redirected to the home page. When I try this in the browser things work fine.

But here it fails on the last step --- instead of the expected result (the home page), the login page is loading, meaning that somehow it seems I lost the user session. Am I missing something? When I call Visit is it creating a new Capybara session?

    scenario "be albe to log in and log out" do
      # login with good user
      logged_in_as_role_for_practice(:practice_user, "My Practice")
      confirm_home_page_loaded

      # try to go to login and should redirect to home
      visit('login')
      confirm_home_page_loaded  # THIS IS FAILING HERE - the login page is loading!!!
   end


Thanks,

David

David Kahn

unread,
Dec 16, 2010, 4:27:40 PM12/16/10
to ste...@googlegroups.com
Sorry... user error :) All is well and as expected.

David Kahn

unread,
Dec 16, 2010, 4:46:08 PM12/16/10
to ste...@googlegroups.com
Actually not solved. It is if I run under Selenum (but there is no js being tested so I dont want to do this), but when I use without Selenium, it seems that the session is lost. Is Capybara not able to keep state between calls to visit(page) within the same scenario? The data in my db is persisting however.

On Thu, Dec 16, 2010 at 3:17 PM, David Kahn <d...@structuralartistry.com> wrote:

David Kahn

unread,
Dec 16, 2010, 4:57:34 PM12/16/10
to ste...@googlegroups.com
This was the problem: I was logging in and ending up on "host/home/index". Then I was asking for "visit('login'), which I think was going here: "host/home/index/login", which of course does not exist. When I call visit('/login') then all is well.

Sorry for all the posts.
Reply all
Reply to author
Forward
0 new messages