Can't flush Mongo DB when running test
I'm using rails
, mongoid
, spork
, rspec
.
As I run tests through, rspec
I see more and more records in my database. Neither purge!
, nor database_cleaner
did they help.
My test:
describe MyConvertor do
context 'working with my model'
before(:each) do
FactoryGirl.create :my_model
end
# examples go here
end
end
And my helper spec:
Spork.each_run do
RSpec.configure do |config|
# ...
config.before(:each) do
Mongoid.purge!
end
# ...
end
end
As I said, I also tried database_cleaner
, but nothing changed:
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
So, I have several questions at once: why does purge!
nothing and why DatabaseCleaner
does not work.
I found a problem with cleaning up the database , but there is no useful solution.
I use
rails 3.2.11
mongoid 3.0.23
source to share
I had this on Mac OSX el capitain:
on the terminal:
brew doctor
he showed me this warning:
"Warning: /usr/bin occurs before /usr/local/bin This means that system-provided programs will be used instead of those provided by Homebrew."
Then I needed to reorder / etc / paths, making "usr / local / bin" and "/ usr / local / sbin" on top.
on the terminal again:
sudo vi /etc/paths
/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
This solved the problem when I had this.
source to share