Cleaning test databases faster

Edgars Beigarts
MAKIT
Published in
1 min readDec 12, 2016

--

We have been using database_cleaner for years and recently found out about database_rewinder which is a bit faster with projects that have a lot of tables. Unfortunately it didn't support Mongoid, ActiveRecord transactions and used monkey patches for ActiveRecord classes, so we decided to create a new gem.

Main Features

  • No monkey patching — uses ActiveSupport::Notifications and Mongo::Monitoring::Global to catch INSERTstatements
  • Fast :deletion strategy that cleans only tables/collections where INSERT statements were performed
  • Faster disable_referential_integrity for PostgreSQL
  • Executes multiple DELETE statements as one query with ActiveRecord
  • Supports only one database for each ORM

--

--