# Database Cleaner Database Cleaner is a set of strategies for cleaning your database in Ruby. The original use case was to ensure a clean state during tests. Each strategy is a small amount of code but is code that is usually needed in any ruby app that is testing with a database. ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, and CouchPotato are supported. [![Build Status](https://secure.travis-ci.org/bmabey/database_cleaner.png)](http://travis-ci.org/bmabey/database_cleaner) Here is an overview of the strategies supported for each library:
ORM | Truncation | Transaction | Deletion |
---|---|---|---|
ActiveRecord | Yes | Yes | Yes |
DataMapper | Yes | Yes | No |
CouchPotato | Yes | No | No |
MongoMapper | Yes | No | No |
Mongoid | Yes | No | No |
Sequel | Yes | Yes | No |
Driver | Truncation | Transaction | Deletion |
---|---|---|---|
Mongo | Yes | No | No |
ORM | How to access | Notes |
---|---|---|
Active Record | DatabaseCleaner[:active_record] |
Connection specified as :symbol keys, loaded from config/database.yml . You may also pass in the ActiveRecord model under the :model key. |
Data Mapper | DatabaseCleaner[:data_mapper] |
Connection specified as :symbol keys, loaded via Datamapper repositories |
Mongo Mapper | DatabaseCleaner[:mongo_mapper] |
Multiple connections not yet supported |
Mongoid | DatabaseCleaner[:mongoid] |
Multiple databases supported for Mongoid 3. Specify DatabaseCleaner[:mongoid, {:connection => :db_name}] |
Couch Potato | DatabaseCleaner[:couch_potato] |
Multiple connections not yet supported |
Sequel | DatabaseCleaner[:sequel] |
Multiple databases supported; specify Databasecleaner[:sequel, {:connection => Sequel.connect(uri)}] |