Ruby on rails Can';运行测试时,无法清除Mongo DB

Ruby on rails Can';运行测试时,无法清除Mongo DB,ruby-on-rails,mongodb,rspec,mongoid,database-cleaner,Ruby On Rails,Mongodb,Rspec,Mongoid,Database Cleaner,我使用的是rails,mongoid,spork,rspec 在通过rspec运行测试时,我看到数据库中的记录数量不断增加。无论是清除或数据库\u cleaner没有帮助 我的测试是: describe MyConvertor do context 'working with my model' before(:each) do FactoryGirl.create :my_model end # examples go here end end 我

我使用的是
rails
mongoid
spork
rspec

在通过
rspec
运行测试时,我看到数据库中的记录数量不断增加。无论是
清除
数据库\u 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
正如我前面提到的,我也尝试了
数据库\u 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

我在Mac OSX el capitain上看到了这个:

在终端上:

brew doctor
它向我展示了这个警告:

"Warning: /usr/bin occurs before /usr/local/bin This means that system-provided programs will be used instead of those provided by Homebrew."
然后我需要更改/etc/path中的顺序,使“usr/local/bin”和“/usr/local/sbin”位于顶部

再次在终端上:

sudo vi /etc/paths

/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
这解决了问题,当我有它