<commit_before># TextMate sets this to 1, which hangs the Firefox driver
ENV.delete "DYLD_FORCE_FLAT_NAMESPACE"

require "test_helper"
require "selenium-webdriver"

class WebDriverTestCase < ActiveSupport::TestCase
  attr_accessor :base_url
  attr_accessor :driver
  
  self.use_transactional_fixtures = false
  self.use_instantiated_fixtures  = false
  fixtures :all
  
  def setup
    # TODO use API for FF profile: http://seleniumhq.org/docs/09_webdriver.html
    webdriver_profile = Selenium::WebDriver::Firefox::Profile.new(Rails.root + "test/fixtures/webdriver-profile")
    @driver = Selenium::WebDriver.for(:firefox, :profile => webdriver_profile)
    FileUtils.rm_rf download_directory
    FileUtils.mkdir_p download_directory
    Test::Unit::UI::WebDriverTestRunner.driver = driver
    @base_url = "http://localhost:3000"
    driver.manage.delete_all_cookies
    super
  end
  
  def teardown
    @driver.try :quit
    super
  end
  
  def open(url, expect_error_page = false)
    driver.get base_url + url
    if expect_error_page
      assert_errors
    else
      assert_no_errors
    end
  end
  
  def refresh
    driver.navigate.refresh
    assert_no_errors
  end
  
  def back
    driver.navigate.back
  end<commit_msg>Try to workaround Webdriver-Firefox connection hanging<commit_after># TextMate sets this to 1, which hangs the Firefox driver
ENV.delete "DYLD_FORCE_FLAT_NAMESPACE"

require "test_helper"
require "selenium-webdriver"

class WebDriverTestCase < ActiveSupport::TestCase
  attr_accessor :base_url
  attr_accessor :driver
  
  self.use_transactional_fixtures = false
  self.use_instantiated_fixtures  = false
  fixtures :all
  
  def setup
    # TODO use API for FF profile: http://seleniumhq.org/docs/09_webdriver.html
    webdriver_profile = Selenium::WebDriver::Firefox::Profile.new(Rails.root + "test/fixtures/webdriver-profile")
    @driver = Selenium::WebDriver.for(:firefox, :profile => webdriver_profile)
    FileUtils.rm_rf download_directory
    FileUtils.mkdir_p download_directory
    Test::Unit::UI::WebDriverTestRunner.driver = driver
    @base_url = "http://localhost:3000"
    driver.manage.delete_all_cookies
    super
  end
  
  def teardown
    begin
      begin
        Timeout::timeout(5) do
          @driver.try :quit
        end
      rescue Timeout::Error => e
        Rails.logger.warn "Could not quit Firefox driver"
      end
      super
    rescue Exception => e
      Rails.logger.error e
    end
  end
  
  def open(url, expect_error_page = false)
    driver.get base_url + url
    if expect_error_page
      assert_errors
    else
      assert_no_errors
    end
  end
  
  def refresh
    driver.navigate.refresh
    assert_no_errors
  end
  
  def back
    driver.navigate.back
  end
{'fraction_non_alphanumeric': 0.07459970887918486, 'fraction_numerical': 0.0054585152838427945, 'mean_word_length': 3.405448717948718, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '116218', 'n_tokens_mistral': 914, 'n_tokens_neox': 880, 'n_words': 197}