<commit_before>module CucumberRailsHelper
  def rails_new(options = {})
    options[:name] ||= 'test_app'
    command = run "bundle exec rails new #{options[:name]} --skip-bundle --skip-test-unit --skip-spring #{options[:args]}"
    expect(command).to have_output /README/
    expect(last_command_started).to be_successfully_executed
    cd options[:name]
    delete_environment_variable 'RUBYOPT'
    delete_environment_variable 'BUNDLE_BIN_PATH'
    delete_environment_variable 'BUNDLE_GEMFILE'
    # Force older version of nokogiri on older Rubies
    gem 'nokogiri', '~> 1.6.8' if RUBY_VERSION < '2.1.0'
    run_simple 'bundle install'
  end

  def install_cucumber_rails(*options)
    if options.include?(:not_in_test_group)
      gem 'cucumber-rails', path: "#{File.expand_path('.')}"
    else
      gem 'cucumber-rails' , group: :test, require: false, path: "#{File.expand_path('.')}"
    end
    # From Rails 5.1 capybara is already part of the Gemfile
    gem 'capybara', group: :test if Gem.latest_spec_for('rails').version < Gem::Version.new('5.1.0')
    gem 'rspec-rails', group: :test
    gem 'database_cleaner', group: :test unless options.include?(:no_database_cleaner)
    gem 'factory_girl', group: :test unless options.include?(:no_factory_girl)
    gem 'selenium-webdriver', group: :test
    # Newer versions of rake remove a method used by RSpec older versions
    # See https://stackoverflow.com/questions/35893584/nomethoderror-undefined-method-last-comment-after-upgrading-to-rake-11#35893625
    if Gem::Version.new(RSpec::Support::Version::STRING) < Gem::Version.new('3.4.4')
      gem 'rake', '< 11.0'
      run_simple 'bundle update rake --local'
    end
    run_simple 'bundle exec rails generate cucumber:install'
  end

  def gem(name, options)
    line = %{gem "#{name}", #{options.inspect}\n}
    append_to_file('Gemfile', line)
  end

  def prepare_aruba_report
    if(ENV['ARUBA_REPORT_DIR'])
      @aruba_report_start = Time.new
      sleep(1)
    end
  end

  def fixture(path)
    File.expand_path(File.dirname(__FILE__) + "./../support/fixtures/#{path}")
  end
end
World(CucumberRailsHelper)
<commit_msg>Ensure selenium-wedriver 3 is not selected for tests<commit_after>module CucumberRailsHelper
  def rails_new(options = {})
    options[:name] ||= 'test_app'
    command = run "bundle exec rails new #{options[:name]} --skip-bundle --skip-test-unit --skip-spring #{options[:args]}"
    expect(command).to have_output /README/
    expect(last_command_started).to be_successfully_executed
    cd options[:name]
    delete_environment_variable 'RUBYOPT'
    delete_environment_variable 'BUNDLE_BIN_PATH'
    delete_environment_variable 'BUNDLE_GEMFILE'
    # Force older version of nokogiri on older Rubies
    gem 'nokogiri', '~> 1.6.8' if RUBY_VERSION < '2.1.0'
    run_simple 'bundle install'
  end

  def install_cucumber_rails(*options)
    if options.include?(:not_in_test_group)
      gem 'cucumber-rails', path: "#{File.expand_path('.')}"
    else
      gem 'cucumber-rails' , group: :test, require: false, path: "#{File.expand_path('.')}"
    end
    # From Rails 5.1 some gems are already part of the Gemfile
    if Gem.loaded_specs['rails'].version < Gem::Version.new('5.1.0')
      gem 'capybara', group: :test
      gem 'selenium-webdriver', group: :test
    else
      # Make sure to restrict the selected selenium-webdriver version
      # Since version 3 geckodriver is required to be installed
      gemfile_text = File.read(expand_path('Gemfile'))
      gemfile_text.gsub!("gem 'selenium-webdriver'", "gem 'selenium-webdriver', '~> 2.0'")
      overwrite_file('Gemfile', gemfile_text)
    end
    gem 'rspec-rails', group: :test
    gem 'database_cleaner', group: :test unless options.include?(:no_database_cleaner)
    gem 'factory_girl', group: :test unless options.include?(:no_factory_girl)
    # Newer versions of rake remove a method used by RSpec older versions
    # See https://stackoverflow.com/questions/35893584/nomethoderror-undefined-method-last-comment-after-upgrading-to-rake-11#35893625
    if Gem::Version.new(RSpec::Support::Version::STRING) < Gem::Version.new('3.4.4')
      gem 'rake', '< 11.0'
      run_simple 'bundle update rake --local'
    end
    run_simple 'bundle exec rails generate cucumber:install'
  end

  def gem(name, options)
    line = %{gem "#{name}", #{options.inspect}\n}
    append_to_file('Gemfile', line)
  end

  def prepare_aruba_report
    if(ENV['ARUBA_REPORT_DIR'])
      @aruba_report_start = Time.new
      sleep(1)
    end
  end

  def fixture(path)
    File.expand_path(File.dirname(__FILE__) + "./../support/fixtures/#{path}")
  end
end
World(CucumberRailsHelper)

{'fraction_non_alphanumeric': 0.13053712818317997, 'fraction_numerical': 0.016263642199871604, 'mean_word_length': 3.930379746835443, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 6, 'https://': 2, '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': '7582916', 'n_tokens_mistral': 1625, 'n_tokens_neox': 1563, 'n_words': 358}