I'm having difficulty running multiple integration tests on Rails 4 (now called system tests in Rails 5).
Environment: Rails 4 / Minitest / Capybara / Poltergeist running on the Puma server.
When I run a single test that creates a new record, it works every time.
RAILS_ENV="test" ruby -I test test/integration/requests_test.rb -n /create_new/
When I run the entire set of tests, the above test fails to create every time because the record already exists.
RAILS_ENV="test" ruby -I test test/integration/requests_test.rb
I confirmed this by adding puts Request.all.collect(&:name)
at the start - when running the group, the record being created already in the DB.
Here's the core issue - the DB is not reliably fresh for every test. (It is fresh for my unit tests and my functional tests, in groups and as individuals.) How can I make sure that my integration tests also start fresh each time?
In case it's helpful, the command above seems to be running Puma in development mode, even though I've specified ENV['RAILS_ENV'] = 'test'
in test_helper.rb
.