<commit_before>ENV['RAILS_ENV'] ||= 'test'
require_relative 'dummy/config/environment'

require 'rspec/rails'

require 'capybara/rspec'
require 'capybara/poltergeist'
require 'database_cleaner'
require 'factory_girl_rails'
require 'pry-byebug'

Rails.backtrace_cleaner.remove_silencers!
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }

Capybara.default_driver = :poltergeist

RSpec.configure do |config|
  config.expect_with :rspec do |expectations|
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end

  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end

  config.use_transactional_fixtures = false
  config.filter_run :focus
  config.run_all_when_everything_filtered = true

  config.warnings = ENV['SHOW_WARNING']

  if config.files_to_run.one?
    config.default_formatter = 'doc'
  end

  config.profile_examples = 10
  config.order = :random

  config.include FactoryGirl::Syntax::Methods
  Kernel.srand config.seed

  config.around(:each, :fog_mock) do |example|
    begin
      Fog.mock!
      Fog::Mock.reset

      example.run
    ensure
      Fog.unmock!
    end
  end

  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
    DatabaseCleaner.clean_with :truncation
  end

  config.around(:each) do |example|
    begin
      if example.metadata[:type] == :feature
        DatabaseCleaner.strategy = :truncation
      end

      DatabaseCleaner.cleaning do
        example.run
      end
    ensure
      DatabaseCleaner.strategy = :transaction
    end
  end
end<commit_msg>Do'not use txn for sqlite3 cleaning<commit_after>ENV['RAILS_ENV'] ||= 'test'
require_relative 'dummy/config/environment'

require 'rspec/rails'

require 'capybara/rspec'
require 'capybara/poltergeist'
require 'database_cleaner'
require 'factory_girl_rails'
require 'pry-byebug'

Rails.backtrace_cleaner.remove_silencers!
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }

Capybara.default_driver = :poltergeist

RSpec.configure do |config|
  config.expect_with :rspec do |expectations|
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end

  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end

  config.use_transactional_fixtures = false
  config.filter_run :focus
  config.run_all_when_everything_filtered = true

  config.warnings = ENV['SHOW_WARNING']

  if config.files_to_run.one?
    config.default_formatter = 'doc'
  end

  config.profile_examples = 10
  config.order = :random

  config.include FactoryGirl::Syntax::Methods
  Kernel.srand config.seed

  config.around(:each, :fog_mock) do |example|
    begin
      Fog.mock!
      Fog::Mock.reset

      example.run
    ensure
      Fog.unmock!
    end
  end

  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.clean_with :truncation
  end

  config.around(:each) do |example|
    DatabaseCleaner.cleaning do
      example.run
    end
  end
end
{'fraction_non_alphanumeric': 0.09704220671319375, 'fraction_numerical': 0.001661681621801263, 'mean_word_length': 3.9834437086092715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2928780', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1007, 'n_words': 193}