Reputation: 11
I have an application in rails 5.2.6 to which I am doing the test with RSPEC and Capybara and for it I have a test database with data that I use to perform the tests and I am running some tests that generate data that are stored in this database. What I need is that after running the tests these data are not stored in it.
I have used the gem database_cleaner but this cleans all the data of the test db and I only want to erase the data that are generated by the tests.
part of my database.yml:
development:
<<: *default
database: f_development
host: localhost
port: 5432
username: postgres
password: postgres
test:
<<: *default
database: f_test
host: localhost
port: 5432
username: postgres
password: postgres
Upvotes: 1
Views: 835
Reputation: 26
Check your spec/rails_helper.rb configure section. Looks like you have set
config.use_transactional_fixtures = false
What means to not execute every test in transaction so data stays in the database.
Default behavior for this setting is true.
Yo can read how it work here
Another solution what can help you: you can setup seeding data before running test like described here
Upvotes: 0