Sha256: 0433e0c80fa57c16caefb7ea05a759ec5850214a2ebba0406f93074ed6221e17

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 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 = :transaction
        DatabaseCleaner.start

        example.run

        DatabaseCleaner.clean
      end

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

        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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspeckled-0.0.30 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.29 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.28 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.27 lib/rspeckled/plugins/database_cleaner.rb