I am trying to get the RSpec examples working with Capybara using the javascript driver (w / Webkit or Poltergeist), but when updating the table there is a database lock problem. Here is part of the example in question:
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"
I use Devise Warden::Test::Helpersto login as well.
Starting RSpec takes some time, and all I get is:
Failure/Error: visit "/contracts/#{contract.id}/edit"
Capybara::Driver::Webkit::WebkitInvalidResponseError:
Unable to load URL: http://127.0.0.1:46520/contracts/1/edit
The log shows that the database lock problem is:
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
I tried a lot of things (this question seemed to be closest to the real solution: Capybara with: js => true causes the test to fail ), but nothing worked, even getting rid of DatabaseCleaner. Can I try something else?
. spec_helper.rb : https://gist.github.com/2855631