提交 91d22b78 编写于 作者: E eileencodes

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
上级 a136c291
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册