Open ChrisBr opened 9 years ago
you better merge webui and api for real and then you don't need this crap and can use transactions
Not really, because ActiveRecord creates a new connection to the database for each thread. That becomes a problem when you use Capybara because it setups it's own connection and won't see the data you create. So this isn't related to webui <-> api but to Capybara js tests.
When we
use_js
in a test, the database is in an inconsistent state! This caused us yesterday some headaches...http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/
We already have the database_cleaner gem in our Gemfile, unfortunately we don't really use it. When I change our testhelper to sth like this:
the behavior of the tests is like expected.
But changing this would slow down our testsuite. We should only use this for our Capybara / functional tests. We would need for instance 'minitest-metadata' gem to annotate our tests like
it 'does sth', js: true
to setup database_cleaner in our setup function accordingly.This is just as a reminder, we don't need that now but I wanted to document this for the future.