Hello,
I'm wondering what's the recommended Sequel test setup when using Capybara
with a JS driver that runs the Rack app server in a background thread.
Ideally, I would like tests to run inside a transaction, in which case the
DB connection would have to be shared between the test thread and the
background app. This is what I came up with:
DB = Sequel.connect("...", max_connections: 1)
RSpec.configure do |c|
c.around(:each) do |spec|
DB.transaction(rollback: :always, auto_savepoint: true) do
DB.pool.send(:release, Thread.current) # allow the app to use the
connection
spec.run
end
end
end
Does that look ok? If yes, do you think we could add it to the testing
guide?
The alternative would be not having a transaction, but rather
truncating/deleting data after each test run using something like
DatabaseCleaner, but I guess that would have a too significant performance
impact (I don't have a large enough app to verify that, though).
Kind regards,
Janko
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/2dce448b-b773-44d8-979d-3f974612679fn%40googlegroups.com.