Permalink
Browse files

Don't call register on custom drivers

It's possible for developers toadd a custom driver and then call it
using `driven_by`. Because we were only skipping `register` for
`:rack_test` that meant any custom driver would attempt to be registered
as well.

The three listed here are special because Rails registers them with
special options. If you're registering your own custom driver then you
don't want to separately register that driver.

Fixes #29688
  • Loading branch information...
eileencodes committed Jul 8, 2017
1 parent ff7f4a7 commit 6a28aa5bb6a331d84baf542892e94744f0299690
@@ -9,14 +9,14 @@ def initialize(name, **options)
end
def use
register unless rack_test?
register if registerable?
setup
end
private
def rack_test?
@name == :rack_test
def registerable?
[:selenium, :poltergeist, :webkit].include?(@name)
end
def register
@@ -29,7 +29,7 @@ class DriverTest < ActiveSupport::TestCase
assert_equal ({ skip_image_loading: true }), driver.instance_variable_get(:@options)
end
test "rack_test? returns false if driver is poltergeist" do
assert_not ActionDispatch::SystemTesting::Driver.new(:poltergeist).send(:rack_test?)
test "registerable? returns false if driver is rack_test" do
assert_not ActionDispatch::SystemTesting::Driver.new(:rack_test).send(:registerable?)
end
end

0 comments on commit 6a28aa5

Please sign in to comment.