I\'m trying to pass this spec :
scenario \"Edit a service\", js: true do
service = create_service_for(provider, title: \"First service\")
fill_edit_service_f
I was having different tests fail randomly (like 1 test out of 500, every other time I ran the suite).
This may not be the prettiest solution, but I solved the problem by just rescuing and retrying the database cleaner after 2 seconds, like so:
config.after(:each) do |example|
begin
DatabaseCleaner.clean
rescue Exception => e
# Recover from thread locks and retry the database clean after a slight delay
sleep 2
DatabaseCleaner.clean
end
end