title: Database timeout when running RSpec/Capybara with javascript driver
body: <p>I'm trying to get some RSpec examples working with Capybara using the javascript driver (w/ Webkit or Poltergeist) but there's a locking issue with the database when updating a table. Here's part of the example in question:</p>
  
  <pre><code>  scenario 'by changing the contract attributes', js: true do
      login_as @admin, scope: :user
  
      contract = Contract.create(number: '123',
                                 start_at: Date.today,
                                 end_at: Date.today + 1.month)
  
      visit "/contracts/#{contract.id}/edit"
  </code></pre>
  
  <p>I'm using Devise and the <code>Warden::Test::Helpers</code> to login.</p>
  
  <p>Running RSpec takes a while and all I get:</p>
  
  <pre><code> Failure/Error: visit "/contracts/#{contract.id}/edit"
   Capybara::Driver::Webkit::WebkitInvalidResponseError:
     Unable to load URL: http://127.0.0.1:46520/contracts/1/edit
  </code></pre>
  
  <p>The log is showing that there's a database locking issue:</p>
  
  <pre><code>Started GET "/contracts/1/edit" for 127.0.0.1 at 2012-06-01 12:10:26 -0400
     (0.2ms)  BEGIN
     (51083.3ms)  UPDATE `users` SET `last_sign_in_at` = '2012-06-01 16:10:26', `current_sign_in_at` = '2012-06-01 16:10:26', `last_sign_in_ip` = '127.0.0.1', `current_sign_in_ip` = '127.0.0.1', `sign_in_count` = 1, `updated_at` = '2012-06-01 16:10:26' WHERE `users`.`id` = 1
  Mysql2::Error: Lock wait timeout exceeded; try restarting transaction: UPDATE `users` SET `last_sign_in_at` = '2012-06-01 16:10:26', `current_sign_in_at` = '2012-06-01 16:10:26', `last_sign_in_ip` = '127.0.0.1', `current_sign_in_ip` = '127.0.0.1', `sign_in_count` = 1, `updated_at` = '2012-06-01 16:10:26' WHERE `users`.`id` = 1
     (0.8ms)  ROLLBACK
  </code></pre>
  
  <p>I've tried lots of things (that question seemed to closest to an actual solution: <a href="https://stackoverflow.com/questions/8178120/capybara-with-js-true-causes-test-to-fail">Capybara with :js =&gt; true causes test to fail</a>) but nothing worked, even getting rid of DatabaseCleaner. Is there anything else I could try?</p>
  
  <p><strong>Edit</strong>: Here's the <code>spec_helper.rb</code> file as requested: <a href="https://gist.github.com/2855631" rel="nofollow noreferrer">https://gist.github.com/2855631</a></p>