我正在嘗試使用JavaScript驅動程序(w/Webkit或Poltergeist)使用Capybara來獲得一些RSpec示例,但更新表時數據庫存在鎖定問題。這裏是有問題的示例的一部分:使用JavaScript驅動運行RSpec/Capybara時數據庫超時
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"
我使用的設計和Warden::Test::Helpers
登錄。
運行RSpec的需要一段時間,我得到:
Failure/Error: visit "/contracts/#{contract.id}/edit"
Capybara::Driver::Webkit::WebkitInvalidResponseError:
Unable to load URL: http://127.0.0.1:46520/contracts/1/edit
的日誌中顯示,有一個數據庫鎖定問題:
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
我試過很多東西(這個問題似乎以最接近實際的解決方案:Capybara with :js => true causes test to fail),但沒有任何工作,甚至擺脫DatabaseCleaner。還有什麼我可以嘗試嗎?
編輯:這裏的spec_helper.rb
文件的要求:https://gist.github.com/2855631
你能發佈你的spec_helper文件嗎? – DVG
@DVG我編輯了我的問題,並提供了一個要點鏈接。 –