Sha256: 61bf31bcd1a4a759d7dba5dcea9e64856a9596bbd14fe8e37f02d645017f0157

Contents?: true

Size: 1.03 KB

Versions: 23

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require "rspec"
require "database_cleaner/active_record"

# see https://github.com/DatabaseCleaner/database_cleaner#how-to-use
RSpec.configure do |config|
  config.use_transactional_fixtures = false

  config.before(:suite) do
    DatabaseCleaner.clean_with :truncation

    # Here we are defaulting to :transaction but swapping to deletion for some specs;
    # if your spec or its code-under-test uses
    # nested transactions then specify :transactional e.g.:
    #   describe "SomeWorker", :transactional do
    #
    DatabaseCleaner.strategy = :transaction

    config.before(:context, transactional: true) { DatabaseCleaner.strategy = :deletion }
    config.after(:context, transactional: true) { DatabaseCleaner.strategy = :transaction }
    config.before(:context, type: :system) { DatabaseCleaner.strategy = :deletion }
    config.after(:context, type: :system) { DatabaseCleaner.strategy = :transaction }
  end

  config.around(:each) do |example|
    DatabaseCleaner.cleaning do
      example.run
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
acidic_job-1.0.0.pre9 lib/acidic_job/rspec_configuration.rb
acidic_job-1.0.0.pre8 lib/acidic_job/rspec_configuration.rb
acidic_job-1.0.0.pre7 lib/acidic_job/rspec_configuration.rb