<commit_before>require 'simplecov'
SimpleCov.start

ENV['RACK_ENV'] = 'test'

require 'bundler'
Bundler.require :default, :test

require 'rack/test'

Webrat.configure do |config|
  config.mode = :rack
end

Mail.defaults do
  delivery_method :test
end

Sinatra::Base.set :app_root,
                  File.expand_path(File.join(File.dirname(__FILE__), '..'))

Sinatra::Base.set :app_logfile,
                  File.join(settings.app_root, 'logs', 'app-test.log')

Sinatra::Base.set :audit_logfile,
                  File.join(settings.app_root, 'logs', 'audit-test.log')

Sinatra::Base.set :issuer, 'https://rapid.example.org'
Sinatra::Base.set :hostname, 'rapid.example.org'
Sinatra::Base.set :organisations, '/tmp/rspec_organisations.json'
Sinatra::Base.set :federation, 'production'
Sinatra::Base.set :mail, from: '<EMAIL>', to: '<EMAIL>'

Sinatra::Base.set :export, enabled: true
Sinatra::Base.set :export, secret: 'test_secret'

# Supply common framework actions to tests
module AppHelper
  def app
    RapidConnect
  end

  def session
    last_request.env['rack.session']
  end

  def last_email
    Mail::TestMailer.deliveries[0]
  end

  def flush_stores
    @redis.flushall
    Mail::TestMailer.deliveries.clear
  end

  def flash
    last_request.env['x-rack.flash']
  end
end

RSpec.configure do |config|<commit_msg>Add workaround for legacy RSpec matcher warnings<commit_after>require 'simplecov'
SimpleCov.start

ENV['RACK_ENV'] = 'test'

require 'bundler'
Bundler.require :default, :test

require 'rack/test'

Webrat.configure do |config|
  config.mode = :rack
end

Mail.defaults do
  delivery_method :test
end

Sinatra::Base.set :app_root,
                  File.expand_path(File.join(File.dirname(__FILE__), '..'))

Sinatra::Base.set :app_logfile,
                  File.join(settings.app_root, 'logs', 'app-test.log')

Sinatra::Base.set :audit_logfile,
                  File.join(settings.app_root, 'logs', 'audit-test.log')

Sinatra::Base.set :issuer, 'https://rapid.example.org'
Sinatra::Base.set :hostname, 'rapid.example.org'
Sinatra::Base.set :organisations, '/tmp/rspec_organisations.json'
Sinatra::Base.set :federation, 'production'
Sinatra::Base.set :mail, from: '<EMAIL>', to: '<EMAIL>'

Sinatra::Base.set :export, enabled: true
Sinatra::Base.set :export, secret: 'test_secret'

legacy_rspec_matchers = [
  Webrat::Matchers::HasContent,
  Mail::Matchers::HasSentEmailMatcher
]

legacy_rspec_matchers.each do |m|
  m.instance_eval do
    alias_method :failure_message_when_negated, :negative_failure_message
  end
end

# Supply common framework actions to tests
module AppHelper
  def app
    RapidConnect
  end

  def session
    last_request.env['rack.session']
  end

  def last_email
    Mail::TestMailer.deliveries[0]
  end

  def flush_stores
    @redis.flushall
    Mail::TestMailer.deliveries.clear
  end

  def flash
    last_request.env['x-rack.flash']
  end
end

RSpec.configure do |config|
{'fraction_non_alphanumeric': 0.12884483937115515, 'fraction_numerical': 0.000683526999316473, 'mean_word_length': 4.162257495590829, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6253073', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1026, 'n_words': 208}