nudesign/rails_template — Issue #1: Configurar o database_cleaner no rspec
Author: tiagogodinho
Created: 2011-11-10 21:15:58+00:00
State: open

O database_cleaner é usado em todo projeto com mongoid.

`spec/spec_helper.rb`

```ruby
RSpec.configure do |config|
...

config.before(:suite) do
DatabaseCleaner.orm = :mongoid
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end

config.after(:suite) do
Mongoid.master.connection.drop_database("#{Mongoid.master.name}")
end

config.before(:each) do
DatabaseCleaner.start
end

config.after(:each) do
DatabaseCleaner.clean
end
end
```