単体テストを実行して mongo db をクリアするたびにセットアップを実行したいのですが、mongoid でどのように行うのですか?
グーグルでいくつかのリンクを見つけましたが、何も機能していないようです。
の出力rake -T
rake db:drop # Drops all the collections for the database for the current Rails.env
..
rake db:mongoid:drop # Drops the database for the current Rails.env
rake db:mongoid:purge # Drop all collections except the system collections
..
rake db:purge # Drop all collections except the system collections
仕様でデータベースのクリーニングを抽象化するdatabase_cleaner gem をご覧になることをお勧めします。
Rails を使用している場合は、実行rake db:mongoid:purge
して、システム コレクションを除くすべてのコレクションを削除できます。
または、実行rake db:mongoid:drop
して現在の Rails.env からデータベースを削除します。