<commit_before>ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
#require 'watir-webdriver'
require 'selenium-webdriver'

class TestCase < Test::Unit::TestCase
  def browser_url
    ENV['BROWSER_URL'] || 'http://localhost:3000'
  end

  def browser_instance
    if !@browsers
      @browsers = []
    end
    if !ENV['REMOTE_URL']
      browser = Selenium::WebDriver.for :firefox 
      @browsers.push browser
      return browser
    end
#    return Watir::Browser.new if !ENV['REMOTE_URL']

    caps = Selenium::WebDriver::Remote::Capabilities.send( ENV['BROWSER'] )
    caps.platform = ENV['BROWSER_OS'] || 'Windows 2008'
    caps.version  = ENV['BROWSER_VERSION'] || '8'
    Selenium::WebDriver.for(
      :remote,
      :url                  => ENV['REMOTE_URL'],
      :desired_capabilities => caps,
    )

  end

  def teardown
    return if !@browsers
    @browsers.each{ |browser|
      browser.close
    }
  end

  # Add more helper methods to be used by all tests here...
  def browser_login(data)
    all_tests = [
      {
        :name     => 'login',
        :instance => data[:instance] || browser_instance,
        :url      => data[:url] || browser_url,
        :action   => [
          {<commit_msg>Small improvements/cleanup.<commit_after>ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
#require 'watir-webdriver'
require 'selenium-webdriver'

class TestCase < Test::Unit::TestCase
  def browser_url
    ENV['BROWSER_URL'] || 'http://localhost:3000'
  end

  def browser_instance
    if !@browsers
      @browsers = []
    end
    if !ENV['REMOTE_URL']
      if !ENV['BROWSER']
        ENV['BROWSER'] = 'firefox'
      end
      browser = Selenium::WebDriver.for( ENV['BROWSER'].to_sym )
      @browsers.push browser
      return browser
    end

    caps = Selenium::WebDriver::Remote::Capabilities.send( ENV['BROWSER'] )
    caps.platform = ENV['BROWSER_OS'] || 'Windows 2008'
    caps.version  = ENV['BROWSER_VERSION'] || '8'
    browser = Selenium::WebDriver.for(
      :remote,
      :url                  => ENV['REMOTE_URL'],
      :desired_capabilities => caps,
    )
    @browsers.push browser
    return browser
  end

  def teardown
    return if !@browsers

    # only shut down browser type once
    # otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)"
    shutdown = {}
    @browsers.each{ |browser|
      next if shutdown[ browser.browser ]
      shutdown[ browser.browser ] = true
      browser.quit
    }
  end

  # Add more helper methods to be used by all tests here...
  def browser_login(data)
    all_tests = [
      {
        :name     => 'login',
        :instance => data[:instance] || browser_instance,
        :url      => data[:url] || browser_url,
        :action   => [
          {
{'fraction_non_alphanumeric': 0.1338392549154881, 'fraction_numerical': 0.006553984132459468, 'mean_word_length': 2.666245259165613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1333376', 'n_tokens_mistral': 997, 'n_tokens_neox': 931, 'n_words': 206}