# frozen_string_literal: true ############################################################################## # Database Cleaner Plugin ############################################################################## begin require 'database_cleaner' begin autodetected = DatabaseCleaner::Base.new.__send__(:autodetect) rescue DatabaseCleaner::NoORMDetected autodetected = false end if autodetected RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.clean_with(:truncation) end config.around(:each) do |example| DatabaseCleaner.strategy = :transaction DatabaseCleaner.start example.run DatabaseCleaner.clean end config.around(:each, :js => true) do |example| DatabaseCleaner.strategy = :truncation example.run end end if defined? RSpec::Rails RSpec.configure do |config| config.use_transactional_fixtures = false end end end rescue LoadError if defined? RSpec::Rails RSpec.configure do |config| config.use_transactional_fixtures = true end end end