Created
January 18, 2014 10:28
-
-
Save mtkd/8488633 to your computer and use it in GitHub Desktop.
Using DatabaseCleaner with Mongo Driver and Minitest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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