Here is a integration test case with capybara in rails 3.2.12. click_link 'New Log'
is an ajax call. However the page opened starts with $() and has a bunch of js escape like \n and \log-log.
it "should work with link on show customer_comm_record page" do
visit customer_customer_comm_records_path(@cust)
#visit customer_customer_comm_record_path(@cust, @crecord)
click_link @crecord.id.to_s
click_link 'New Log'
save_and_open_page
end
We also tried to wrap the case with describe "", :js => true do
, how there is an error saying
`An error occurred in an after hook ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked:`
There is no error out of code execution. What's wrong with the rspec case? Thanks for help.
It looks like your server is locking the database so that the test cannot clean up after it has run.
When you use Capybara without JavaScript the tests and server are all running in a single process and thread. This means they can share the same database connection and transaction. This means that RSpec can use a simple database transaction to roll back changes at the end of the test and why you don't see any lock contention between test and server.
When you run with :js => true
things are a little different, the server starts up in a separate thread or process to your tests so they will each be using a separate database connection and transaction. This means that the database transaction strategy that RSpec uses by default to clean up won't work. It is also causing lock errors in your case.
The Capybara readme talks about this problem and recommends database_cleaner gem as an alternative in this situation. You will need to configure database cleaner to use the truncation strategy rather than transactions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With