osem-fcy/spec/support/database_cleaner.rb
Ana María Martínez Gómez 7ebf44d1e4 Improvements in the DatabaseCleaner
Move all what is related to the DatabaseCleaner to the
database_cleaner.rb file. Load the seeds only when they have been
deleted and not before every test.
2017-01-11 10:03:27 +01:00

16 lines
435 B
Ruby

RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
Rails.application.load_seed
end
config.before(:each) do |example|
DatabaseCleaner.strategy = (example.metadata[:js] == true) ? :truncation : :transaction
DatabaseCleaner.start
end
config.after(:each) do |example|
DatabaseCleaner.clean
Rails.application.load_seed if example.metadata[:js] == true
end
end