diff options
Diffstat (limited to 'actionpack/lib/action_dispatch')
4 files changed, 11 insertions, 30 deletions
diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb index efc3988bc3..5f711c7348 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -52,5 +52,11 @@ module ActionDispatch ActionDispatch.test_app = app end + + initializer "action_dispatch.system_tests" do |app| + ActiveSupport.on_load(:action_dispatch_system_test_case) do + include app.routes.url_helpers + end + end end end diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb index 066daa4a12..a7fb5fa330 100644 --- a/actionpack/lib/action_dispatch/system_test_case.rb +++ b/actionpack/lib/action_dispatch/system_test_case.rb @@ -10,7 +10,6 @@ require "action_dispatch/system_testing/browser" require "action_dispatch/system_testing/server" require "action_dispatch/system_testing/test_helpers/screenshot_helper" require "action_dispatch/system_testing/test_helpers/setup_and_teardown" -require "action_dispatch/system_testing/test_helpers/undef_methods" module ActionDispatch # = System Testing @@ -110,12 +109,11 @@ module ActionDispatch # Because <tt>ActionDispatch::SystemTestCase</tt> is a shim between Capybara # and Rails, any driver that is supported by Capybara is supported by system # tests as long as you include the required gems and files. - class SystemTestCase < IntegrationTest + class SystemTestCase < ActiveSupport::TestCase include Capybara::DSL include Capybara::Minitest::Assertions include SystemTesting::TestHelpers::SetupAndTeardown include SystemTesting::TestHelpers::ScreenshotHelper - include SystemTesting::TestHelpers::UndefMethods def initialize(*) # :nodoc: super @@ -160,6 +158,10 @@ module ActionDispatch driven_by :selenium + def url_options # :nodoc: + default_url_options.merge(host: Capybara.app_host) + end + ActiveSupport.run_load_hooks(:action_dispatch_system_test_case, self) end diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb index 7080dbe022..20f6a7634f 100644 --- a/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb @@ -7,7 +7,6 @@ module ActionDispatch DEFAULT_HOST = "http://127.0.0.1" def host!(host) - super Capybara.app_host = host end diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb deleted file mode 100644 index d64be3b3d9..0000000000 --- a/actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module ActionDispatch - module SystemTesting - module TestHelpers - module UndefMethods # :nodoc: - extend ActiveSupport::Concern - included do - METHODS = %i(get post put patch delete).freeze - - METHODS.each do |verb| - undef_method verb - end - - def method_missing(method, *args, &block) - if METHODS.include?(method) - raise NoMethodError, "System tests cannot make direct requests via ##{method}; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information." - else - super - end - end - end - end - end - end -end |