<commit_before>require 'metar_taf'
require 'metar/metar_expectations'

describe Metar::Parser do
  describe '#parse' do
    METAR_EXPECTATIONS.each do |obj|
      parser = Metar::Parser.new(obj[:raw])
      parser.process
      it { expect(parser.parsed).to eq(obj[:parsed]) }
    end

    METAR_EXPECTATIONS.each do |obj|
      humanizer = Metar::Humanizer.new(obj[:raw])
      humanizer.read
      it { expect(humanizer.readable).to eq(obj[:readable]) }
    end

    Dir.glob('spec/metar/resources/invalid/*.TXT') do |metar|
      it "should raise a parser error on #{metar}" do
        expect { @humanizer = Metar::Humanizer.new(File.readlines(metar, encoding: 'ISO-8859-1')[1]) }.to raise_error(Error::ParserError)
      end
    end
  end

  OUTPUT_READABLE = false

  describe 'parse all files' do
    f = File.open('tmp/parsing.txt', 'a') if OUTPUT_READABLE<commit_msg>moved a test where it belongs<commit_after>require 'metar_taf'
require 'metar/metar_expectations'

describe Metar::Parser do
  describe '#parse' do
    METAR_EXPECTATIONS.each do |obj|
      parser = Metar::Parser.new(obj[:raw])
      parser.process
      it { expect(parser.parsed).to eq(obj[:parsed]) }
    end
  end

  describe '#read' do
    METAR_EXPECTATIONS.each do |obj|
      humanizer = Metar::Humanizer.new(obj[:raw])
      humanizer.read
      it { expect(humanizer.readable).to eq(obj[:readable]) }
    end
  end

  OUTPUT_READABLE = false

  describe 'parse and read all files' do
    Dir.glob('spec/metar/resources/invalid/*.TXT') do |metar|
      it "should raise a parser error on #{metar}" do
        expect { @humanizer = Metar::Humanizer.new(File.readlines(metar, encoding: 'ISO-8859-1')[1]) }.to raise_error(Error::ParserError)
      end
    end

    f = File.open('tmp/parsing.txt', 'a') if OUTPUT_READABLE
{'fraction_non_alphanumeric': 0.13255684969495285, 'fraction_numerical': 0.0066555740432612314, 'mean_word_length': 3.4433497536945814, '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': '3481791', 'n_tokens_mistral': 637, 'n_tokens_neox': 610, 'n_words': 138}