Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rspec Integration Test not Cleaning the Database

The database is not being cleaned after each integration test. The value stays in the database.

Is there an option I should have to make this happen?

Thanks

like image 728
donald Avatar asked Apr 09 '11 21:04

donald


2 Answers

I think https://github.com/bmabey/database_cleaner is what you need.

like image 124
mikewilliamson Avatar answered Oct 28 '22 14:10

mikewilliamson


For anyone using before(:all) hooks, be aware that these hooks are executed before the transaction associated to the fixture is opened. This means that any data created by before(:all) hooks will not be rolled back by transactional fixtures. You can read more in the RSpec documentation.

I just wanted to mention this because I was bit by it and my initial instinct was to jump to Database Cleaner (which wound up not being needed and eventually not working).

like image 33
TMcManemy Avatar answered Oct 28 '22 14:10

TMcManemy