<commit_before>require 'simplecov'
SimpleCov.start

require 'minitest/autorun'
require 'usesthis'
require 'json'

def test_site
  @site ||= UsesThis::Site.new(Dimples::Configuration.new(
    'source_path' => File.join(__dir__, 'source'),
    'destination_path' => File.join(File::SEPARATOR, 'tmp', 'site', "usesthis-#{Time.new.to_i}"),
    'class_overrides' => {
      'site' => 'UsesThis::Site',
      'post' => 'UsesThis::Interview'
    }
  ))
end

def read_api_file(path = nil)
  path = File.join(test_site.output_paths[:site], 'api', path, 'index.json')
  JSON.load(File.read(path))
end

def read_fixture(name)
  path = File.join(__dir__, 'fixtures', "#{name}.json")
  JSON.load(File.read(path))
end<commit_msg>Add a test_configuration, temp_site_path and test_interview method, switch to JSON.parse.<commit_after>require 'simplecov'
SimpleCov.start

require 'minitest/autorun'
require 'usesthis'
require 'json'

def test_site
  @test_site ||= UsesThis::Site.new(test_configuration)
end

def test_configuration
  @test_configuration ||= Dimples::Configuration.new(
    'source_path' => File.join(__dir__, 'source'),
    'destination_path' => temp_site_path,
    'class_overrides' => {
      'site' => 'UsesThis::Site',
      'post' => 'UsesThis::Interview'
    }
  )
end

def temp_site_path
  File.join(File::SEPARATOR, 'tmp', "usesthis-#{Time.new.to_i}")
end

def test_interview
  @test_interview ||= read_fixture('interview')
end

def read_api_file(path = nil)
  path = File.join(test_site.output_paths[:site], 'api', path, 'index.json')
  JSON.parse(File.read(path))
end

def read_fixture(name)
  path = File.join(__dir__, 'fixtures', "#{name}.json")
  JSON.parse(File.read(path))
end
{'fraction_non_alphanumeric': 0.16499112950916617, 'fraction_numerical': 0.0, 'mean_word_length': 5.220588235294118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5850679', 'n_tokens_mistral': 619, 'n_tokens_neox': 631, 'n_words': 111}