RailsApps/rails3-mongoid-devise — Issue #14: Problem with DatabaseCleaner, and solution
Author: JohnLockwood
Created: 2012-02-26 22:16:57+00:00
State: open

Hi,

Don't know if this is pilot error or what, but I thought I'd mention it in case it's helpful. For some reason I was having trouble with the DatabaseCleaner code in spec_helper.rb, complaining about the mongoid connection. Because there was no connection, needless to say all the tests were failing. My solution was to yank out DatabaseCleaner and add code based on http://adventuresincoding.com/2010/07/how-to-configure-cucumber-and-rspec-to-work-with-mongoidra, specifically:

config.before :each do
Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
end