私は、、、を使用しrails
てmongoid
いspork
ますrspec
。
経由でテストを実行してrspec
いるときに、データベース内のレコード数が増えていることがわかります。どちらpurge!
もdatabase_cleaner
役に立ちませんでした。
私のテストは次のとおりです。
describe MyConvertor do
context 'working with my model'
before(:each) do
FactoryGirl.create :my_model
end
# examples go here
end
end
そして、私の仕様ヘルパーは次のとおりです。
Spork.each_run do
RSpec.configure do |config|
# ...
config.before(:each) do
Mongoid.purge!
end
# ...
end
end
前に述べたように、私も試しdatabase_cleaner
てみましたが、状況は変わりませんでした:
Spork.prefork do
RSpec.configure do |config|
config.order = "random"
config.use_transactional_fixtures = false
end
end
Spork.each_run do
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner[:mongoid].strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
end
だから私は一度にいくつかの質問があります.purge!
なぜ何もしないのか、そしてなぜDatabaseCleaner
うまくいかないのか.
データベース クリーナーの問題が見つかりましたが、有効な解決策はありません。
私は使っている
rails 3.2.11
mongoid 3.0.23