Sha256: 5b82abb595b01776c5ed7fdffba75d44a175c5cd0e00c458b4c80f8d7274d735

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 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)
      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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rspeckled-0.0.26 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.25 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.24 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.23 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.22 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.21 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.20 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.19 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.18 lib/rspeckled/plugins/database_cleaner.rb
rspeckled-0.0.17 lib/rspeckled/plugins/database_cleaner.rb