Sha256: fc496fae1e0dc275ec21dbc86e99cd9047fd976c77373c4913ca359acac93236

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

begin
  autodetected = ::DatabaseCleaner::Base.new.__send__(:autodetect)
rescue ::DatabaseCleaner::NoORMDetected
  autodetected = false
end

return unless autodetected

RSpec.configure do |config|
  config.before(:suite) do
    config.rspeckled_logger.debug("Before Suite - Start - #{__FILE__}")

    ::DatabaseCleaner.clean_with(:truncation, :except => %w{ar_internal_metadata})

    config.rspeckled_logger.debug("Before Suite - End   - #{__FILE__}")
  end

  config.around(:each) do |example|
    config.rspeckled_logger.debug("Around Each  - Start - #{__FILE__}")

    ::DatabaseCleaner.strategy = if example.metadata[:js] || %i{mongoid}.include?(autodetected)
                                   [:truncation, :except => %w{ar_internal_metadata}]
                                 else
                                   :transaction
                                 end

    ::DatabaseCleaner.start

    example.run

    ::DatabaseCleaner.clean

    config.rspeckled_logger.debug("Around Each  - End   - #{__FILE__}")
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rspeckled-1.4.0 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.3.1 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.3.0 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.2.1 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.2.0 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.1.3 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.1.2 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.1.1 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.1.0 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.0.5 lib/rspeckled/plugins/hooks/database_cleaner.rb
rspeckled-1.0.4 lib/rspeckled/plugins/hooks/database_cleaner.rb