ruby on rails - Capybara and chrome driver: SQLite3::BusyException: database is locked -


once in while use chromedriver when running feature specs visual testing etc. this, set driver: :chrome on specific spec.

i didn't long time seems, since tried today, got following error:

sqlite3::busyexception: database locked 

this doesn't happen when running specs using default javascript driver (which poltergeist).

a search on google lead solution shows how monkey patch active record. still, feels odd me. why did work before? threading issue? don't monkey patching, maybe there's better solution this.

according this feature in cucumber-rails:

when running scenario @javascript tag, capybara fire web server in same process in separate thread cukes. default, means activerecord give separate database connection, in turn means data put database cucumber step definitions (e.g. using factorygirl) won't visible web server until database transaction committed.

so if use transaction strategy cleaning database @ end of scenario, won't work javascript scenarios default.

there 2 ways around this. 1 switch truncation strategy javascript scenarios. slower, more reliable.

the alternative patch activerecord share single database connection between threads. means still speed benefits of using transaction roll database, run risk of 2 threads stomping on 1 talk database.

right now, default behavior use truncation, can override telling cucumber-rails strategy use javascript scenarios.

the deletion strategy can quicker situations truncation causes locks has been reported oracle users.

from last paragraph, use deletion strategy changing following line in env.rb:

cucumber::rails::database.javascript_strategy = :truncation 

by:

cucumber::rails::database.javascript_strategy = :deletion 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -