<commit_before>$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'cafe_blog-core'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|
  
end

LibDirBase = File.expand_path('../../lib', __FILE__)
def clear_environment
  CafeBlog::Core::Environment.instance_variable_set(:@instance, nil)
  mmod = CafeBlog::Core::Model
  mmod.constants.each do |c|
    mmod.instance_eval { remove_const c } if mmod.const_get(c) < Sequel::Model
  end
  $LOADED_FEATURES.delete_if {|x| x =~ %r!cafe_blog/core/model/.*$! }
end<commit_msg>add: shared_context 'Environment.setup'<commit_after>$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'cafe_blog-core'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|
  
end

LibDirBase = File.expand_path('../../lib', __FILE__)
def clear_environment
  CafeBlog::Core::Environment.instance_variable_set(:@instance, nil)
  mmod = CafeBlog::Core::Model
  mmod.constants.each do |c|
    mmod.instance_eval { remove_const c } if mmod.const_get(c) < Sequel::Model
  end
  $LOADED_FEATURES.delete_if {|x| x =~ %r!cafe_blog/core/model/.*$! }
end

MigrationDirectory = File.expand_path('../../bin/migration', __FILE__)
shared_context 'Environment.setup' do
  before :all do
    clear_environment

    @database = Sequel.connect('sqlite:///')
    require 'sequel/extensions/migration'
    Sequel::Migrator.run(@database, MigrationDirectory)

    @environment = CafeBlog::Core::Environment.setup(:database => @database)
  end
  after :all do
    @database.drop_tables(*@database.tables) rescue nil
  end
end
{'fraction_non_alphanumeric': 0.15704967385850477, 'fraction_numerical': 0.0, 'mean_word_length': 5.116564417177914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '1415038', 'n_tokens_mistral': 696, 'n_tokens_neox': 685, 'n_words': 135}