<commit_before># frozen_string_literal: true
require 'spec_helper'
require 'yaml'
require 'cucumber/cli/options'

module Cucumber
  module Cli
    describe Options do

      def given_cucumber_yml_defined_as(hash_or_string)
        allow(File).to receive(:exist?) { true }

        cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string

        allow(IO).to receive(:read).with('cucumber.yml') { cucumber_yml }
      end

      before(:each) do
        allow(File).to receive(:exist?) { false } # Meaning, no cucumber.yml exists
        allow(Kernel).to receive(:exit)
      end

      def output_stream
        @output_stream ||= StringIO.new
      end

      def error_stream
        @error_stream ||= StringIO.new
      end

      def options
        @options ||= Options.new(output_stream, error_stream)
      end

      def prepare_args(args)
        args.is_a?(Array) ? args : args.split(' ')
      end

      describe 'parsing' do

        def when_parsing(args)
          yield
          options.parse!(prepare_args(args))
        end

        def after_parsing(args)
          options.parse!(prepare_args(args))
          yield
        end

        context '-r or --require' do
          it 'collects all specified files into an array' do
            after_parsing('--require some_file.rb -r another_file.rb') do
              expect(options[:require]).to eq ['some_file.rb', 'another_file.rb']
            end
          end
        end

        context '--i18n-languages' do
          include RSpec::WorkInProgress

          it 'lists all known languages' do
            when_parsing '--i18n-languages' do
              expect(Kernel).to receive(:exit)
            end
          end
<commit_msg>Fix test to assert that the languages list is displayed<commit_after># frozen_string_literal: true
require 'spec_helper'
require 'yaml'
require 'cucumber/cli/options'

module Cucumber
  module Cli
    describe Options do

      def given_cucumber_yml_defined_as(hash_or_string)
        allow(File).to receive(:exist?) { true }

        cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string

        allow(IO).to receive(:read).with('cucumber.yml') { cucumber_yml }
      end

      before(:each) do
        allow(File).to receive(:exist?) { false } # Meaning, no cucumber.yml exists
        allow(Kernel).to receive(:exit)
      end

      def output_stream
        @output_stream ||= StringIO.new
      end

      def error_stream
        @error_stream ||= StringIO.new
      end

      def options
        @options ||= Options.new(output_stream, error_stream)
      end

      def prepare_args(args)
        args.is_a?(Array) ? args : args.split(' ')
      end

      describe 'parsing' do

        def when_parsing(args)
          yield
          options.parse!(prepare_args(args))
        end

        def after_parsing(args)
          options.parse!(prepare_args(args))
          yield
        end

        context '-r or --require' do
          it 'collects all specified files into an array' do
            after_parsing('--require some_file.rb -r another_file.rb') do
              expect(options[:require]).to eq ['some_file.rb', 'another_file.rb']
            end
          end
        end

        context '--i18n-languages' do
          include RSpec::WorkInProgress

          it 'lists all known languages' do
            after_parsing '--i18n-languages' do
              ::Gherkin::DIALECTS.keys.map do |key|
                expect(@output_stream.string).to include(key.to_s);
              end
            end
          end

{'fraction_non_alphanumeric': 0.0956738768718802, 'fraction_numerical': 0.0022185246810870773, 'mean_word_length': 2.0619694397283532, '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': '7466337', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1051, 'n_words': 253}