Nov 21, 2011 · 1 min
Cucumber and Mysql2::Error Lock when deleting records
I was writing some cucumber features for reru_scrum when I ran into an issue with destroying user records and Mysql2 throwing a Lock error.
The full error:
1Mysql2::Error: Lock wait timeout exceeded; try restarting transaction: UPDATE `users` SET `last_sign_in_at` = '2011-11-22 00:06:32', `current_sign_in_at` = '2011-11-22 00:11:28', `sign_in_count` = 3, `updated_at` = '2011-11-22 00:11:28' WHERE `users`.`id` = 1A simple solution is to use the database_cleaner gem.
Inside your features/support/env.rb file:
1begin
2 require 'database_cleaner'
3 require 'database_cleaner/cucumber'
4 DatabaseCleaner.strategy = :truncation
5rescue NameError
6 raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
7end