Skip to content

Instantly share code, notes, and snippets.

@mtkd
Created January 18, 2014 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtkd/8488633 to your computer and use it in GitHub Desktop.
Save mtkd/8488633 to your computer and use it in GitHub Desktop.
Using DatabaseCleaner with Mongo Driver and Minitest
# not obvious from the database_cleaner documentation
# this is snippets of relevant parts, it's not meant to run
require 'mongo'
require 'database_cleaner'
require 'database_cleaner/mongo/base'
include Mongo
@mongo_client = MongoClient.new
DatabaseCleaner[:mongo].strategy = :truncation
DatabaseCleaner[:mongo].db = @mongo_client.db("default")
module MiniTest
class Spec
def setup
DatabaseCleaner.start
end
def teardown
DatabaseCleaner.clean
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment