jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

The driver_options configuration option is always set to nil if it isn't specified in the environment for rake, overriding other options #413

Closed lexi-lambda closed 9 years ago

lexi-lambda commented 9 years ago

I set the driver options in my teaspoon_env:

config.driver_options = ['--ignore-ssl-errors=yes']

However, the options seemed to be completely ignored when I ran the tests from the CLI. I dug into the Teaspoon code, and I found that the options are indeed being set, but they're getting unset afterwards.

Specifically, the problem originates all the way up in teaspoon.rake. It fetches the options from the environment:

options = {
  files: ENV["files"].nil? ? [] : ENV["files"].split(","),
  suite: ENV["suite"],
  coverage: ENV["coverage"],
  driver_options: ENV["driver_options"],
}

This then gets handed down to Teaspoon.configuration.override_from_options, which blindly sets each value, even if it's nil:

def self.override_from_options(options)
  options.each { |k, v| override(k, v) }
end

It might be better to ignore nil values in this method, something like this:

options.compact.each { |k, v| override(k, v) }

I'm not sure what would be best given the other options, though. Perhaps it should be handled higher up in the call stack?

mikepack commented 9 years ago

Thanks for submitting this issue, Alexis. A fix is in master if you'd like to give it a try, or it will go out with the next release.