<commit_before>require File.expand_path("../spec_helper", __FILE__)

WatirSpec.implementation do |imp|
  name    = :webdriver
  browser = (ENV['WATIR_WEBDRIVER_BROWSER'] || :firefox).to_sym

  imp.name          = name
  imp.browser_class = Watir::Browser

  if browser == :firefox && ENV['NATIVE_EVENTS'] == "true"
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile.native_events = true

    imp.browser_args = [:firefox, {:profile => profile}]
  elsif browser == :chrome && ENV['NATIVE_EVENTS'] == "true"
    imp.browser_args = [:chrome, {:native_events => true}]
  else
    imp.browser_args = [browser]
  end

  imp.guard_proc = lambda { |args|
    args.any? { |arg| arg == name || arg == browser || arg == [name, browser]}
  }
end


<commit_msg>Add the ability to differentiate native vs synthesized events when running specs.<commit_after>require File.expand_path("../spec_helper", __FILE__)

WatirSpec.implementation do |imp|
  browser = (ENV['WATIR_WEBDRIVER_BROWSER'] || :firefox).to_sym

  imp.name          = :webdriver
  imp.browser_class = Watir::Browser

  use_native_events = ENV['NATIVE_EVENTS'] == "true"

  if browser == :firefox && use_native_events
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile.native_events = true

    imp.browser_args = [:firefox, {:profile => profile}]
  elsif browser == :chrome && use_native_events
    imp.browser_args = [:chrome, {:native_events => true}]
  else
    imp.browser_args = [browser]
  end

  matching_guards = [
    :webdriver,            # guard only applies to webdriver
    browser,               # guard only applies to this browser
    [:webdriver, browser]  # guard only applies to this browser on webdriver
  ]

  if use_native_events || (Selenium::WebDriver::Platform.windows? && [:firefox, :ie].include?(browser))
    # guard only applies to this browser on webdriver with native events enabled
    matching_guards << [:webdriver, browser, :native_events]
  else
    # guard only applies to this browser on webdriver with native events disabled
    matching_guards << [:webdriver, browser, :synthesized_events]
  end

  imp.guard_proc = lambda { |args|
    args.any? { |arg| matching_guards.include?(arg) }
  }
end



{'fraction_non_alphanumeric': 0.12516884286357496, 'fraction_numerical': 0.0, 'mean_word_length': 3.819956616052061, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7424131', 'n_tokens_mistral': 724, 'n_tokens_neox': 685, 'n_words': 175}