Topic: Failing to test Devise with Capybara

Hi All,

I'm building a Rails 3 app using Devise, with Capybara for UI testing. The following test is failing:

class AuthenticationTest < ActionController::IntegrationTest

  def setup
    @user = User.create!(:email => '', 
                         :password => 'testtest', 
                         :password_confirmation => 'testtest')!

  test "sign_in" do
    # this proves the user exists in the database ...
    assert_equal 1, User.count
    assert_equal '',

    # ... but we still can't log in ...
    visit '/users/sign_in'
    assert page.has_content?('Sign in')
    fill_in :user_email, :with => ''
    fill_in :user_password, :with => 'testtest'

    # ... because this test fails
    assert page.has_content?('Signed in successfully.')


... but I have no idea why. As you can see from the code, the user is being created in the database; I'm using the same approach to create the user as I did in seeds.rb.

If I run the test through the debugger, I can see the user in the database and verify that the page is loading. But still the authentication fails; I can verify this because if I change the assertion to test for the failure case, the test passes:

# verify that the authentication actually failed
assert page.has_content?('Invalid email or password.')

I'm used to Rails 2, & using Selenium for this sort of testing, so I suspect I'm doing something daft. Could someone please point me in the right direction here?

Re: Failing to test Devise with Capybara

did you solve this problem? I am having this same issue