<commit_before>require 'spec_helper'

describe Termislator::UserInputParser do
  describe "initialization" do
    it "raises error if argument is not a ARGV options array" do
      expect { Termislator::UserInputParser.new :wrong_data }.to raise_error ArgumentError
    end
  end

  describe "options method" do
    context "when user has not given any arguments" do
      it "raises error" do
        parser = Termislator::UserInputParser.new []
        expect{ parser.options }.to raise_error ArgumentError
      end
    end

    context "when user has specified the options" do
      it "without the -v flag" do
        parser = Termislator::UserInputParser.new ['en', 'fr', 'your mother']
        expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother', voice: false })
      end

      it "with the -v flag" do
        parser = Termislator::UserInputParser.new ['en', 'fr', 'your mother', '-v']
        expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother', voice: true })
      end

      it "with text as seperate ARGV array elements" do
        parser = Termislator::UserInputParser.new ['en', 'fr', 'your', 'mother', 'here?', '-v']
        expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother here?', voice: true })
      end

      it "with incorrect language options format raiser error" do
        parser = Termislator::UserInputParser.new ['anglicki', 'po polski', 'your mother', '-v']
        expect{ parser.options }.to raise_error ArgumentError
      end
    end

  end

end<commit_msg>fixed inoput specs<commit_after>require 'spec_helper'

describe Termislator::UserInputParser do
  describe "initialization" do
    it "raises error if argument is not a ARGV options array" do
      expect { Termislator::UserInputParser.new :wrong_data }.to raise_error ArgumentError
    end
  end

  describe "options method" do
    context "when user has not given any arguments" do
      it "raises error" do
        parser = Termislator::UserInputParser.new []
        expect{ parser.options }.to raise_error SystemExit
      end
    end

    context "when user has specified the options" do
      it "without the -v flag" do
        parser = Termislator::UserInputParser.new ['en', 'fr', 'your mother']
        expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother', voice: false })
      end

      it "with the -v flag" do
        parser = Termislator::UserInputParser.new ['en', 'fr', 'your mother', '-v']
        expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother', voice: true })
      end

      it "with text as seperate ARGV array elements" do
        parser = Termislator::UserInputParser.new ['en', 'fr', 'your', 'mother', 'here?', '-v']
        expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother here?', voice: true })
      end

      it "with incorrect language options format raiser error" do
        parser = Termislator::UserInputParser.new ['anglicki', '<NAME>', 'your mother', '-v']
        expect{ parser.options }.to raise_error SystemExit
      end
    end

  end

end
{'fraction_non_alphanumeric': 0.11521603005635567, 'fraction_numerical': 0.0, 'mean_word_length': 3.1493506493506493, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7224367', 'n_tokens_mistral': 954, 'n_tokens_neox': 931, 'n_words': 334}