<commit_before>class SmartAnswerTestHelper
  def self.data_path
    Rails.root.join('test', 'data')
  end

  def self.artefacts_path
    Rails.root.join('test', 'artefacts')
  end

  def self.responses_and_expected_results
    Dir[data_path.join('*-responses-and-expected-results.yml')]
  end

  def initialize(flow_name)
    @flow_name = flow_name
  end

  def question_and_responses_path
    data_path.join(question_and_responses_filename)
  end

  def write_questions_and_responses(questions_and_responses)
    FileUtils.mkdir_p(data_path)
    File.open(question_and_responses_path, 'w') do |file|
      file.puts(questions_and_responses.to_yaml)
    end
  end

  def responses_and_expected_results_path
    data_path.join(responses_and_expected_results_filename)
  end

  def write_responses_and_expected_results(data)
    File.open(responses_and_expected_results_path, 'w') do |file|
      file.puts(data.to_yaml)
    end
  end

  def read_responses_and_expected_results
    responses_and_expected_results_yaml = File.read(responses_and_expected_results_path)
    YAML.load(responses_and_expected_results_yaml)
  end

  def save_output(responses, response)
    filename = [responses.join('-'), 'html'].join('.')
    path = artefacts_path.join(@flow_name)
    FileUtils.mkdir_p(path)
    path_to_output = path.join(filename)
    File.open(path_to_output, 'w') do |file|
      file.puts(response.body)
    end
    path_to_output
  end

  def delete_saved_output_files
    path = artefacts_path.join(@flow_name)
    FileUtils.rm_f(path.join('*.html'))
  end

  private

  def question_and_responses_filename
    "#{@flow_name}-questions-and-responses.yml"
  end

  def responses_and_expected_results_filename
    "#{@flow_name}-responses-and-expected-results.yml"
  end
<commit_msg>Fix deletion of regression test output files<commit_after>class SmartAnswerTestHelper
  def self.data_path
    Rails.root.join('test', 'data')
  end

  def self.artefacts_path
    Rails.root.join('test', 'artefacts')
  end

  def self.responses_and_expected_results
    Dir[data_path.join('*-responses-and-expected-results.yml')]
  end

  def initialize(flow_name)
    @flow_name = flow_name
  end

  def question_and_responses_path
    data_path.join(question_and_responses_filename)
  end

  def write_questions_and_responses(questions_and_responses)
    FileUtils.mkdir_p(data_path)
    File.open(question_and_responses_path, 'w') do |file|
      file.puts(questions_and_responses.to_yaml)
    end
  end

  def responses_and_expected_results_path
    data_path.join(responses_and_expected_results_filename)
  end

  def write_responses_and_expected_results(data)
    File.open(responses_and_expected_results_path, 'w') do |file|
      file.puts(data.to_yaml)
    end
  end

  def read_responses_and_expected_results
    responses_and_expected_results_yaml = File.read(responses_and_expected_results_path)
    YAML.load(responses_and_expected_results_yaml)
  end

  def save_output(responses, response)
    filename = [responses.join('-'), 'html'].join('.')
    path = artefacts_path.join(@flow_name)
    FileUtils.mkdir_p(path)
    path_to_output = path.join(filename)
    File.open(path_to_output, 'w') do |file|
      file.puts(response.body)
    end
    path_to_output
  end

  def delete_saved_output_files
    path = artefacts_path.join(@flow_name)
    FileUtils.rm_f(Dir[path.join('*.html')])
  end

  private

  def question_and_responses_filename
    "#{@flow_name}-questions-and-responses.yml"
  end

  def responses_and_expected_results_filename
    "#{@flow_name}-responses-and-expected-results.yml"
  end

{'fraction_non_alphanumeric': 0.09267480577136515, 'fraction_numerical': 0.0, 'mean_word_length': 4.537634408602151, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1859122', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1255, 'n_words': 182}