aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorFumiaki MATSUSHIMA <mtsmfm@gmail.com>2017-03-08 21:17:44 +0900
committerFumiaki MATSUSHIMA <mtsmfm@gmail.com>2017-03-13 19:59:01 +0900
commitec99107a2982236c726699cbbefc8839de278b93 (patch)
treeab859b4fb4bf8a9ff1b2b6aa10e3ff71a6c8a814 /actionpack
parent11f10840936a323eda1a9eab02521eff9bdccedb (diff)
downloadrails-ec99107a2982236c726699cbbefc8839de278b93.tar.gz
rails-ec99107a2982236c726699cbbefc8839de278b93.tar.bz2
rails-ec99107a2982236c726699cbbefc8839de278b93.zip
Pass options to `driven_by`
Capybara drivers can handle some options such like `url`. ### before ``` # test/test_helper.rb Capybara.register_driver :remote_chrome do |app| Capybara::Selenium::Driver.new(app, browser: :chrome, url: "http://example.com/wd/hub") end # test/application_system_test_case.rb class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :remote_chrome end ``` ### after ``` # test/application_system_test_case.rb class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: {url: "http://chrome:4444/wd/hub"} end ```
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/system_test_case.rb4
-rw-r--r--actionpack/lib/action_dispatch/system_testing/driver.rb3
-rw-r--r--actionpack/test/dispatch/system_testing/driver_test.rb3
3 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb
index 1bf47d2556..9cd4df33ef 100644
--- a/actionpack/lib/action_dispatch/system_test_case.rb
+++ b/actionpack/lib/action_dispatch/system_test_case.rb
@@ -110,8 +110,8 @@ module ActionDispatch
# driven_by :selenium, using: :firefox
#
# driven_by :selenium, screen_size: [800, 800]
- def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400])
- @driver = SystemTesting::Driver.new(driver, using: using, screen_size: screen_size)
+ def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {})
+ @driver = SystemTesting::Driver.new(driver, using: using, screen_size: screen_size, options: options)
end
# Returns the driver object for the initialized system test
diff --git a/actionpack/lib/action_dispatch/system_testing/driver.rb b/actionpack/lib/action_dispatch/system_testing/driver.rb
index 72d132d64f..5cf17883f7 100644
--- a/actionpack/lib/action_dispatch/system_testing/driver.rb
+++ b/actionpack/lib/action_dispatch/system_testing/driver.rb
@@ -5,6 +5,7 @@ module ActionDispatch
@name = name
@browser = options[:using]
@screen_size = options[:screen_size]
+ @options = options[:options]
end
def use
@@ -19,7 +20,7 @@ module ActionDispatch
def register
Capybara.register_driver @name do |app|
- Capybara::Selenium::Driver.new(app, browser: @browser).tap do |driver|
+ Capybara::Selenium::Driver.new(app, { browser: @browser }.merge(@options)).tap do |driver|
driver.browser.manage.window.size = Selenium::WebDriver::Dimension.new(*@screen_size)
end
end
diff --git a/actionpack/test/dispatch/system_testing/driver_test.rb b/actionpack/test/dispatch/system_testing/driver_test.rb
index 8f8777b19f..814e1d707b 100644
--- a/actionpack/test/dispatch/system_testing/driver_test.rb
+++ b/actionpack/test/dispatch/system_testing/driver_test.rb
@@ -8,10 +8,11 @@ class DriverTest < ActiveSupport::TestCase
end
test "initializing the driver with a browser" do
- driver = ActionDispatch::SystemTesting::Driver.new(:selenium, using: :chrome, screen_size: [1400, 1400])
+ 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 "selenium? returns false if driver is poltergeist" do