<commit_before># This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = 'test'
ENV["ERRBIT_LOG_LEVEL"] = 'fatal'
ENV["ERRBIT_USER_HAS_USERNAME"] = 'false'

if ENV['COVERAGE']
  require 'coveralls'
  require 'simplecov'
  Coveralls.wear!('rails') do
    add_filter 'bundle'
  end
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
    SimpleCov::Formatter::HTMLFormatter,
    Coveralls::SimpleCov::Formatter
  ])
  SimpleCov.start('rails') do
    add_filter 'bundle'
  end
end

require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'email_spec'
require 'xmpp4r'
require 'xmpp4r/muc'
require 'mongoid-rspec'
require 'fabrication'
require 'sucker_punch/testing/inline'
require 'errbit_plugin/mock_issue_tracker'

if RUBY_VERSION >= '2.6.0'
  if Rails.version < '5'
    module ActionController
      class TestResponse < ActionDispatch::TestResponse
        def recycle!
          # HACK: to avoid MonitorMixin double-initialize error:
          @mon_mutex_owner_object_id = nil
          @mon_mutex = nil
          initialize
        end
      end
    end
  else
    puts "Monkeypatch for ActionController::TestResponse no longer needed"
  end
end

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Mongoid::Config.truncate!
Mongoid::Tasks::Database.create_indexes
ActionMailer::Base.delivery_method = :test

RSpec.configure do |config|
  config.include Devise::Test::ControllerHelpers, type: :controller
  config.include Mongoid::Matchers, type: :model<commit_msg>Fix ActionController::TestResponse patch of spec/spec_helper.rb<commit_after># This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = 'test'
ENV["ERRBIT_LOG_LEVEL"] = 'fatal'
ENV["ERRBIT_USER_HAS_USERNAME"] = 'false'

if ENV['COVERAGE']
  require 'coveralls'
  require 'simplecov'
  Coveralls.wear!('rails') do
    add_filter 'bundle'
  end
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
    SimpleCov::Formatter::HTMLFormatter,
    Coveralls::SimpleCov::Formatter
  ])
  SimpleCov.start('rails') do
    add_filter 'bundle'
  end
end

require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'email_spec'
require 'xmpp4r'
require 'xmpp4r/muc'
require 'mongoid-rspec'
require 'fabrication'
require 'sucker_punch/testing/inline'
require 'errbit_plugin/mock_issue_tracker'

# a workaround to avoid MonitorMixin double-initialize error
# https://github.com/rails/rails/issues/34790#issuecomment-681034561
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
  if Gem::Version.new(Rails.version) < Gem::Version.new('5.0.0')
    module ActionController
      class TestResponse < ActionDispatch::TestResponse
        def recycle!
          if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
            @mon_data = nil
            @mon_data_owner_object_id = nil
          else
            @mon_mutex = nil
            @mon_mutex_owner_object_id = nil
          end
          initialize
        end
      end
    end
  else
    warn "Monkeypatch for ActionController::TestResponse is no longer needed"
  end
end

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Mongoid::Config.truncate!
Mongoid::Tasks::Database.create_indexes
ActionMailer::Base.delivery_method = :test

RSpec.configure do |config|
  config.include Devise::Test::ControllerHelpers, type: :controller
  config.include Mongoid::Matchers, type: :model
{'fraction_non_alphanumeric': 0.11803364879074658, 'fraction_numerical': 0.00814931650893796, 'mean_word_length': 4.248275862068965, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 1, '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': '6395335', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1211, 'n_words': 283}