diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/system_test_case.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/system_test_case.rb | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb index 9772beb8aa..aae96975c7 100644 --- a/actionpack/lib/action_dispatch/system_test_case.rb +++ b/actionpack/lib/action_dispatch/system_test_case.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -gem "capybara", ">= 2.15" +gem "capybara", ">= 3.26" require "capybara/dsl" require "capybara/minitest" @@ -119,11 +119,6 @@ module ActionDispatch def initialize(*) # :nodoc: super self.class.driver.use - @proxy_route = if ActionDispatch.test_app - Class.new { include ActionDispatch.test_app.routes.url_helpers }.new - else - nil - end end def self.start_application # :nodoc: @@ -164,20 +159,33 @@ module ActionDispatch driven_by :selenium - def url_options # :nodoc: - default_url_options.merge(host: Capybara.app_host) - end + private + def url_helpers + @url_helpers ||= + if ActionDispatch.test_app + Class.new do + include ActionDispatch.test_app.routes.url_helpers - def method_missing(method, *args, &block) - if @proxy_route.respond_to?(method) - @proxy_route.send(method, *args, &block) - else - super + def url_options + default_url_options.reverse_merge(host: Capybara.app_host || Capybara.current_session.server_url) + end + end.new + end end - end - ActiveSupport.run_load_hooks(:action_dispatch_system_test_case, self) - end + def method_missing(name, *args, &block) + if url_helpers.respond_to?(name) + url_helpers.public_send(name, *args, &block) + else + super + end + end - SystemTestCase.start_application + def respond_to_missing?(name, include_private = false) + url_helpers.respond_to?(name) + end + end end + +ActiveSupport.run_load_hooks :action_dispatch_system_test_case, ActionDispatch::SystemTestCase +ActionDispatch::SystemTestCase.start_application |