Sha256: 4e35b5a86e6219c49ff4af53ad71c5f8045c92f882c208cced7846b5334320ad

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

# 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, :except => %w{ar_internal_metadata})
      end

      config.around(:each) do |example|
        DatabaseCleaner.strategy = if example.metadata[:js]
                                     [:truncation, :except => %w{ar_internal_metadata}]
                                   else
                                     :transaction
                                   end

        DatabaseCleaner.start

        example.run

        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

3 entries across 3 versions & 1 rubygems

Version Path
rspeckled-0.0.33 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.32 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.31 lib/rspeckled/plugins/database_cleaner.rb