Sha256: f5b5eab2460edbdf7b9a2aeeb72c5681cea3847f6b7276814f5d6911f37b1cae

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

##############################################################################
#                         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.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

    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspectacular-0.63.0 lib/rspectacular/plugins/database_cleaner.rb
rspectacular-0.62.1 lib/rspectacular/plugins/database_cleaner.rb