<commit_before>unless defined?(I_AM_SPEC_HELPER)
I_AM_ACCEPTANCE_HELPER = true

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rubygems'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'capybara/email/rspec'
require 'capybara-screenshot'
require 'test_request_syncer'
require 'poltergeist_style_overrides'

require 'capybara-screenshot/rspec'
require 'database_cleaner'

require 'pavlov_helper'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each {|f| require f}

RSpec.configure do |config|
  config.filter_run_excluding slow: true unless ENV['RUN_SLOW_TESTS']

  # webkit always has js enabled, so always use this:
  driver = if ENV["USE_SELENIUM"] then :selenium else :poltergeist end

  Capybara.javascript_driver = driver
  Capybara.default_driver = driver

  Capybara.default_wait_time = 5
  Capybara.server_port = 3005

  config.mock_with :rspec

  config.include Acceptance
  config.include FactoryGirl::Syntax::Methods

  config.before(:suite) do
    ElasticSearch.create
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.orm = "mongoid"
    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, { debug: false,
                                               js_errors: false,
                                               timeout: 60 })
    end

  end

  config.before(:each) do
    Capybara.reset!
    ElasticSearch.clean
    Ohm.flush
    DatabaseCleaner.clean
    FactoryGirl.reload

    ElasticSearch.stub synchronous: true
  end

  config.after(:each) do
    TestRequestSyncer.increment_counter
    # after incrementing the counter, no new ajax requests will *start* to run.
    # However, ruby *is* multithreaded, so existing ajax requests must be<commit_msg>also suppress authority logging output in acceptance spec<commit_after>unless defined?(I_AM_SPEC_HELPER)
I_AM_ACCEPTANCE_HELPER = true

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rubygems'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'capybara/email/rspec'
require 'capybara-screenshot'
require 'test_request_syncer'
require 'poltergeist_style_overrides'

require 'capybara-screenshot/rspec'
require 'database_cleaner'

require 'pavlov_helper'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each {|f| require f}

RSpec.configure do |config|
  config.filter_run_excluding slow: true unless ENV['RUN_SLOW_TESTS']

  # webkit always has js enabled, so always use this:
  driver = if ENV["USE_SELENIUM"] then :selenium else :poltergeist end

  Capybara.javascript_driver = driver
  Capybara.default_driver = driver

  Capybara.default_wait_time = 5
  Capybara.server_port = 3005

  config.mock_with :rspec

  config.include Acceptance
  config.include FactoryGirl::Syntax::Methods

  config.before(:suite) do
    ElasticSearch.create
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.orm = "mongoid"
    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, { debug: false,
                                               js_errors: false,
                                               timeout: 60 })
    end
    Authority.logger = nil
  end

  config.before(:each) do
    Capybara.reset!
    ElasticSearch.clean
    Ohm.flush
    DatabaseCleaner.clean
    FactoryGirl.reload

    ElasticSearch.stub synchronous: true
  end

  config.after(:each) do
    TestRequestSyncer.increment_counter
    # after incrementing the counter, no new ajax requests will *start* to run.
    # However, ruby *is* multithreaded, so existing ajax requests must be
{'fraction_non_alphanumeric': 0.09183155758498224, 'fraction_numerical': 0.0035514967021816335, 'mean_word_length': 3.6884661117717004, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5654514', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1229, 'n_words': 298}