How to write a hash to work with a two parameter splat

100 Views Asked by At

I am trying to pass some additional options to a Selenium web driver for running JavaScript tests using Teaspoon. I am unable to get it to recognize the opts.

My config code:

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 180 # 3 mins instead of the default 60 seconds
config.driver_options = HashWithIndifferentAccess.new(client_driver: [:firefox, {http_client: client}])

Given the library code that uses my config options:

driver = ::Selenium::WebDriver.for(driver_options[:client_driver])

where the ::Selenium::WebDriver.for function is defined as:

def self.for(*args)
  WebDriver::Driver.for(*args)
end

where WebDriver::Driver.for is defined as:

def for(browser, opts = {})
  listener = opts.delete(:listener)

  bridge = case browser
           when :firefox, :ff
             Firefox::Bridge.new(opts)
           when :remote
             Remote::Bridge.new(opts)
           when :ie, :internet_explorer
             IE::Bridge.new(opts)
           when :chrome
             Chrome::Bridge.new(opts)
           when :android
             Android::Bridge.new(opts)
           when :iphone
             IPhone::Bridge.new(opts)
           when :opera
             Opera::Bridge.new(opts)
           when :phantomjs
             PhantomJS::Bridge.new(opts)
           when :safari
             Safari::Bridge.new(opts)
           else
             raise ArgumentError, "unknown driver: #{browser.inspect}"
           end

  bridge = Support::EventFiringBridge.new(bridge, listener) if listener

  new(bridge)
end

How do I pass in a (string, hash) for (browser, opts)? With what I have tried, the whole hash [:firefox, {http_client: client}] gets passed into the browser variable.

0

There are 0 best solutions below