Sha256: 88bb39f7466d85b62a7ef2978c4efb10abde0b943430441ca466cfcb67be5c3f

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 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, { :pre_count => true }
      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, DatabaseCleaner::NoORMDetected
  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
rspectacular-0.15.0 lib/rspectacular/plugins/database_cleaner.rb
rspectacular-0.14.1 lib/rspectacular/plugins/database_cleaner.rb
rspectacular-0.14.0 lib/rspectacular/plugins/database_cleaner.rb
rspectacular-0.13.0 lib/rspectacular/plugins/database_cleaner.rb