Skip to content

Instantly share code, notes, and snippets.

@bryancusatis
Created September 17, 2012 16:25
Show Gist options
  • Save bryancusatis/3738306 to your computer and use it in GitHub Desktop.
Save bryancusatis/3738306 to your computer and use it in GitHub Desktop.
Mongoid, DBCleaner, RSpec, no rails
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'database_cleaner'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.after(:each) do
DatabaseCleaner.clean
end
end
require 'mongoid'
Mongoid::Config.connect_to("mongoid_test")
@nebjak
Copy link

nebjak commented May 20, 2013

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment