<commit_before>load File.expand_path( '../spec_helper.rb', File.dirname(__FILE__) )
# encoding: utf-8

describe Metar::Parser do

  context '.for_cccc' do

    it 'returns a loaded parser' do
      station = stub( 'station' )
      raw = stub( 'raw', :metar => "XXXX 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000",
                         :time  => '2010/02/06 16:10' )
      Metar::Station.stub!( :new => station )
      Metar::Raw.stub!( :new => raw )

      parser = Metar::Parser.for_cccc( 'XXXX' )

      parser.                     should     be_a( Metar::Parser )
      parser.station_code.        should     == 'XXXX'
    end
         
  end

  context 'attributes' do

    it 'time obligatory' do
      expect do
        setup_parser('PAIL', "2010/02/06 16:10\nPAIL 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000") 
      end.       to         raise_error( Metar::ParseError )
    end

    it 'date' do
      parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
      parser.date.    should     == Date.new(2010, 2, 6)
    end

    it 'observer_real' do
      parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
      parser.observer.    should     == :real
    end

    it 'wind' do
      parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")<commit_msg>Example for parsing of observer 'corrected'<commit_after>load File.expand_path( '../spec_helper.rb', File.dirname(__FILE__) )
# encoding: utf-8

describe Metar::Parser do

  context '.for_cccc' do

    it 'returns a loaded parser' do
      station = stub( 'station' )
      raw = stub( 'raw', :metar => "XXXX 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000",
                         :time  => '2010/02/06 16:10' )
      Metar::Station.stub!( :new => station )
      Metar::Raw.stub!( :new => raw )

      parser = Metar::Parser.for_cccc( 'XXXX' )

      parser.                     should     be_a( Metar::Parser )
      parser.station_code.        should     == 'XXXX'
    end
         
  end

  context 'attributes' do

    it 'time obligatory' do
      expect do
        setup_parser('PAIL', "2010/02/06 16:10\nPAIL 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000") 
      end.       to         raise_error( Metar::ParseError )
    end

    it 'date' do
      parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
      parser.date.    should     == Date.new(2010, 2, 6)
    end

    context '.observer' do

      it 'real' do
        parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
        parser.observer.          should     == :real
      end

      it 'corrected' do
        parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z COR 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
        parser.observer.          should     == :corrected
      end
      
    end

    it 'wind' do
      parser = setup_parser('PAIL', "2010/02/06 16:10\nPAIL 061610Z 24006KT 1 3/4SM -SN BKN016 OVC030 M17/M20 A2910 RMK AO2 P0000")
{'fraction_non_alphanumeric': 0.11471990464839094, 'fraction_numerical': 0.14809296781883194, 'mean_word_length': 2.1880341880341883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1518382', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1213, 'n_words': 340}