Skip to content

Instantly share code, notes, and snippets.

@mtkd
Created January 18, 2014 10:28
Show Gist options
  • Select an option

  • Save mtkd/8488633 to your computer and use it in GitHub Desktop.

Select an option

Save mtkd/8488633 to your computer and use it in GitHub Desktop.

Revisions

  1. mtkd created this gist Jan 18, 2014.
    25 changes: 25 additions & 0 deletions database_cleaner_mongo_minitest_example.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # 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