<commit_before>ENV["RAILS_ENV"] ||= 'test'

# begin
#   require 'rubygems'
#   require 'spork'
# rescue LoadError => e
# end

def load_all(*patterns)
  patterns.each { |pattern| Dir[pattern].sort.each { |path| load File.expand_path(path) } }
end

def require_all(*patterns)
  options = patterns.pop
  patterns.each { |pattern| Dir[pattern].sort.each { |path| require path.gsub(/^#{options[:relative_to]}\//, '') } }
end

def configure
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'capybara/rspec'
  require 'database_cleaner'
  require 'factory_girl'
  require 'patches/rspec_hash_diff'
  require 'rspec/rails'
  require 'webmock'
  require_all 'spec/support/**/*.rb', :relative_to => 'spec'

  require 'travis/support'
  require 'stringio'

  Travis.logger = Logger.new(StringIO.new)

  RSpec.configure do |c|
    c.filter_run_excluding :js => true if ENV['CI']

    c.mock_with :mocha

    Support.constants.each do |constant|
      c.include Support.const_get(constant)
    end

    c.before :suite do
      DatabaseCleaner.strategy = :truncation
      DatabaseCleaner.clean_with :truncation
    end

    c.before :each do
      DatabaseCleaner.start
      pusher.reset!

      Travis.instance_variable_set(:@config, nil)
      Travis::Notifications::Handler.instance_variable_set(:@subscriptions, nil)
      Travis::Notifications::Handler::Worker.instance_variable_set(:@queues, nil)
      # Travis::Notifications::Handler::Worker.amqp = Support::Mocks::Amqp.new
    end

    c.before :each, :webmock => true do
      Support::GithubApi.mock!
    end

    c.after :each do
      DatabaseCleaner.clean
    end
  end

  WebMock.disable_net_connect!(:allow_localhost => true)
end

if defined?(Spork)
  Spork.prefork  { configure }
  Spork.each_run { load_all 'lib/**/*.rb', '/config/routes.rb' }
else
  configure
end<commit_msg>add the 'fit' alias for focused rpsec tests<commit_after>ENV["RAILS_ENV"] ||= 'test'

# begin
#   require 'rubygems'
#   require 'spork'
# rescue LoadError => e
# end

def load_all(*patterns)
  patterns.each { |pattern| Dir[pattern].sort.each { |path| load File.expand_path(path) } }
end

def require_all(*patterns)
  options = patterns.pop
  patterns.each { |pattern| Dir[pattern].sort.each { |path| require path.gsub(/^#{options[:relative_to]}\//, '') } }
end

def configure
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'capybara/rspec'
  require 'database_cleaner'
  require 'factory_girl'
  require 'patches/rspec_hash_diff'
  require 'rspec/rails'
  require 'webmock'
  require_all 'spec/support/**/*.rb', :relative_to => 'spec'

  require 'travis/support'
  require 'stringio'

  Travis.logger = Logger.new(StringIO.new)

  RSpec.configure do |c|
    c.filter_run_excluding :js => true if ENV['CI']

    c.mock_with :mocha

    Support.constants.each do |constant|
      c.include Support.const_get(constant)
    end

    c.before :suite do
      DatabaseCleaner.strategy = :truncation
      DatabaseCleaner.clean_with :truncation
    end

    c.before :each do
      DatabaseCleaner.start
      pusher.reset!

      Travis.instance_variable_set(:@config, nil)
      Travis::Notifications::Handler.instance_variable_set(:@subscriptions, nil)
      Travis::Notifications::Handler::Worker.instance_variable_set(:@queues, nil)
      # Travis::Notifications::Handler::Worker.amqp = Support::Mocks::Amqp.new
    end

    c.before :each, :webmock => true do
      Support::GithubApi.mock!
    end

    c.after :each do
      DatabaseCleaner.clean
    end

    c.alias_example_to :fit, :focused => true
    c.filter_run :focused => true
    c.run_all_when_everything_filtered = true
  end

  WebMock.disable_net_connect!(:allow_localhost => true)
end

if defined?(Spork)
  Spork.prefork  { configure }
  Spork.each_run { load_all 'lib/**/*.rb', '/config/routes.rb' }
else
  configure
end
{'fraction_non_alphanumeric': 0.13204180474126945, 'fraction_numerical': 0.0, 'mean_word_length': 3.762135922330097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '5659756', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1339, 'n_words': 265}