Installs database cleaner

- preparation for feature tests with capybara
see:
http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/
This commit is contained in:
Chrisbr 2014-05-10 15:55:17 +02:00
parent 546977fc02
commit 8aa68fb84a
5 changed files with 33 additions and 7 deletions

View file

@ -6,7 +6,6 @@ require File.expand_path('../../config/environment', __FILE__)
if Rails.configuration.database_configuration['test']['database'] == ':memory:'
load "#{Rails.root}/db/schema.rb"
load "#{Rails.root}/db/seeds.rb"
end
require 'rspec/rails'
@ -35,7 +34,7 @@ RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
config.use_transactional_fixtures = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing

View file

@ -0,0 +1,22 @@
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, :js => true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end