admin管理员组文章数量:1427307
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:
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'm using Devise and the Warden::Test::Helpers
to login.
Running RSpec takes a while and all I get:
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 is showing that there's a database locking issue:
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've tried lots of things (that question seemed to closest to an actual solution: Capybara with :js => true causes test to fail) but nothing worked, even getting rid of DatabaseCleaner. Is there anything else I could try?
Edit: Here's the spec_helper.rb
file as requested:
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:
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'm using Devise and the Warden::Test::Helpers
to login.
Running RSpec takes a while and all I get:
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 is showing that there's a database locking issue:
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've tried lots of things (that question seemed to closest to an actual solution: Capybara with :js => true causes test to fail) but nothing worked, even getting rid of DatabaseCleaner. Is there anything else I could try?
Edit: Here's the spec_helper.rb
file as requested: https://gist.github./2855631
- Can you post your spec_helper file? – DVG Commented Jun 1, 2012 at 20:56
- @DVG I've edited my question with a link to gist. – Nicolas Buduroi Commented Jun 1, 2012 at 23:01
2 Answers
Reset to default 5It's almost certainly
config.use_transactional_fixtures = true
Which is trying to run your example inside of a transaction, for the purpose of having clean data. Since you're using Database Cleaner, you already have this feature, so set this to false and you should be good to go.
https://www.relishapp./rspec/rspec-rails/docs/transactions
For me the solution was just the opposite :)
I have set it to false
:
config.use_transactional_fixtures = false
And it all worked. With true
it wasn't working just as before.
本文标签: ruby on railsDatabase timeout when running RSpecCapybara with javascript driverStack Overflow
版权声明:本文标题:ruby on rails - Database timeout when running RSpecCapybara with javascript driver - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745489095a2660522.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论