Note that there are some explanatory texts on larger screens.

plurals
  1. POFailing to test Devise with Capybara
    primarykey
    data
    text
    <p>I'm building a Rails 3 app using Devise, with Capybara for UI testing. The following test is failing:</p> <pre><code>class AuthenticationTest &lt; ActionController::IntegrationTest def setup @user = User.create!(:email =&gt; 'test@example.com', :password =&gt; 'testtest', :password_confirmation =&gt; 'testtest') @user.save! Capybara.reset_sessions! end test "sign_in" do # this proves the user exists in the database ... assert_equal 1, User.count assert_equal 'test@example.com', User.first.email # ... but we still can't log in ... visit '/users/sign_in' assert page.has_content?('Sign in') fill_in :user_email, :with =&gt; 'test@example.com' fill_in :user_password, :with =&gt; 'testtest' click_button('user_submit') # ... because this test fails assert page.has_content?('Signed in successfully.') end end </code></pre> <p>... 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. </p> <p>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:</p> <pre><code># verify that the authentication actually failed assert page.has_content?('Invalid email or password.') </code></pre> <p>I'm used to Rails 2, &amp; 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?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload