1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
RSpec.configure do |config| config.use_transactional_fixtures = false config.before(:suite) do DatabaseCleaner.clean_with :truncation DatabaseCleaner.strategy = :transaction end config.around(:each) do |spec| if spec.metadata[:js] # JS => doesn't share connections => can't use transactions spec.run DatabaseCleaner.clean_with :deletion else # No JS/Devise => run with Rack::Test => transactions are ok DatabaseCleaner.start spec.run DatabaseCleaner.clean # see https://github.com/bmabey/database_cleaner/issues/99 begin ActiveRecord::Base.connection.send :rollback_transaction_records, true rescue end end end end |