Login with Capybara

46 views
Skip to first unread message

Jim Harvey

unread,
Jan 12, 2012, 1:31:06 PM1/12/12
to hobo...@googlegroups.com
I'm having trouble logging in to my application with a dummy user using capybara. I'm getting an "infinite redirect" error so I'm wondering if Hobo is somehow not creating the session after "clicking" the login button in my test. Here is the error:

Failure/Error: click_button 'Login'
     Capybara::InfiniteRedirectError:
       redirected more than 5 times, check for infinite redirects.
     # (eval):2:in `click_button'
     # ./spec/requests/home_page_spec.rb:14:in `block (3 levels) in <top (required)>

The test.log shows that the redirect is going back and forth between:

Started GET "/login" for 127.0.0.1 at 2012-01-12 10:26:27 -0800
  Processing by UsersController#login as HTML
and
Started GET "/" for 127.0.0.1 at 2012-01-12 10:26:27 -0800
  Processing by FrontController#index as HTML

and here my test, if it helps:
describe "..." do
    it "...etc etc... " do
      visit user_login_path
      fill_in 'login', :with => @user.email_address
      fill_in 'password', :with => "Please"
      click_button 'Login'
      page.should_not have_content("...")
    end
  end

Let me know if you need more code/info. This one is really confounding me... Thanks!

Bryan Larsen

unread,
Jan 12, 2012, 1:56:36 PM1/12/12
to hobo...@googlegroups.com
Sorry, I can't really say much beyond "It works for me". The testing
branch of agility-gitorial uses capybara to log in successfully.
Maybe you can take a look at that to see what it's doing differently
from your app.

https://github.com/Hobo/agility-gitorial/tree/testing

The other thing to try is to use selenium with capybara -- seeing what
it's doing in a browser often helps pinpoint the issues. Once it
works in the browser you can switch back to webrat.

cheers,
Bryan

> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/9UHoD6YapYwJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

Ignacio Huerta

unread,
Jan 12, 2012, 2:45:13 PM1/12/12
to hobo...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm working with Hobo + Rspec + Capybara and I've seen this before. I
believe it was a weird bug with sessions in RackTest (one of the
drivers of Capybara).

As Bryan suggested try with the Selenium driver. In my case I'm
currently working with the Webkit driver, and I also use Selenium to
debug when I get lost.

Regards,
Ignacio

El 12/01/12 19:31, Jim Harvey escribi�:

- --
Ignacio Huerta Arteche
http://www.ihuerta.net
Tel�fono: 0034 645 70 77 35
Email realizado con software libre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8POEkACgkQBPlUJ6RHaOSmagCgqnqrusZWwFycLTsm4nht9ozR
/AsAoKtOgKYmewh00rmKQcOjMSRD/lkK
=rgsK
-----END PGP SIGNATURE-----

Ignacio Huerta

unread,
Jan 12, 2012, 2:55:24 PM1/12/12
to hobo...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maybe this is related to this?

https://github.com/tablatom/hobo/pull/31

Regards,
Ignacio

El 12/01/12 19:31, Jim Harvey escribi�:

- --

Ignacio Huerta Arteche
http://www.ihuerta.net
Tel�fono: 0034 645 70 77 35
Email realizado con software libre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8POqwACgkQBPlUJ6RHaOTxkgCg9sJlzGMhngkBJaQ+7hLSL6r0
MaEAoK7Wm9rtFMViUo5CKa+2i0NfplCi
=Lj1v
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages