<commit_before>require 'rails_helper'
require "#{Rails.root}/lib/from_yaml"
require "#{Rails.root}/lib/training_module"

describe FromYaml do
  describe '.load' do
    let(:subject) do
      FromYaml.load(path_to_yaml: "#{Rails.root}/spec/support/bad_yaml_file.yml",
                    cache_key: 'test')
    end
    it 'raises an error if a loaded file is misformatted' do
      expect { subject }.to raise_error(NoMethodError)
    end
  end

  describe '.all' do
    it 'loads from yaml files if data is not in cache' do
      Rails.cache.clear<commit_msg>Test the intended error handling of FromYaml more precisely<commit_after>require 'rails_helper'
require "#{Rails.root}/lib/from_yaml"
require "#{Rails.root}/lib/training_module"

describe FromYaml do
  describe '.load' do
    let(:subject) do
      FromYaml.load(path_to_yaml: "#{Rails.root}/spec/support/bad_yaml_file.yml",
                    cache_key: 'test')
    end
    it 'outputs the filename when loading a misformatted file causes an error' do
      expect(STDOUT).to receive(:puts).with(/.*bad_yaml_file.*/)
      expect { subject }.to raise_error(NoMethodError)
    end
  end

  describe '.all' do
    it 'loads from yaml files if data is not in cache' do
      Rails.cache.clear
{'fraction_non_alphanumeric': 0.1064, 'fraction_numerical': 0.0, 'mean_word_length': 3.240677966101695, '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': '5418891', 'n_tokens_mistral': 411, 'n_tokens_neox': 398, 'n_words': 115}