Database Cleaner:
group :test do ...
gem "database_cleaner"
...
end
Support
# spec/support/factory_girl.rb
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.before(:suite) do
begin
DatabaseCleaner.start
# lint all the factories
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end
end
end
# This should be in rails_helper
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# spec/factories.rb:
FactoryGirl.define do
end