1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/dispatch/system_testing/driver_test.rb
eileencodes 91d22b7832 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
2017-07-08 11:13:28 -04:00

35 lines
1.8 KiB
Ruby

require "abstract_unit"
require "action_dispatch/system_testing/driver"
class DriverTest < ActiveSupport::TestCase
test "initializing the driver" do
driver = ActionDispatch::SystemTesting::Driver.new(:selenium)
assert_equal :selenium, driver.instance_variable_get(:@name)
end
test "initializing the driver with a browser" do
driver = ActionDispatch::SystemTesting::Driver.new(:selenium, using: :chrome, screen_size: [1400, 1400], options: { url: "http://example.com/wd/hub" })
assert_equal :selenium, driver.instance_variable_get(:@name)
assert_equal :chrome, driver.instance_variable_get(:@browser)
assert_equal [1400, 1400], driver.instance_variable_get(:@screen_size)
assert_equal ({ url: "http://example.com/wd/hub" }), driver.instance_variable_get(:@options)
end
test "initializing the driver with a poltergeist" do
driver = ActionDispatch::SystemTesting::Driver.new(:poltergeist, screen_size: [1400, 1400], options: { js_errors: false })
assert_equal :poltergeist, driver.instance_variable_get(:@name)
assert_equal [1400, 1400], driver.instance_variable_get(:@screen_size)
assert_equal ({ js_errors: false }), driver.instance_variable_get(:@options)
end
test "initializing the driver with a webkit" do
driver = ActionDispatch::SystemTesting::Driver.new(:webkit, screen_size: [1400, 1400], options: { skip_image_loading: true })
assert_equal :webkit, driver.instance_variable_get(:@name)
assert_equal [1400, 1400], driver.instance_variable_get(:@screen_size)
assert_equal ({ skip_image_loading: true }), driver.instance_variable_get(:@options)
end
test "registerable? returns false if driver is rack_test" do
assert_not ActionDispatch::SystemTesting::Driver.new(:rack_test).send(:registerable?)
end
end