From 4533bb7dcbdd6e0451395bc869d6c3603c6ff1df Mon Sep 17 00:00:00 2001 From: eileencodes Date: Sun, 11 Sep 2016 13:33:52 -0400 Subject: Fix Railtie to pass class when setting options This will clean up the railtie quite a bit, rather than passing a set of hash keys call the new class directly like we do with ActiveJob. Only call driver once when tests start rather than in every single test setup. This is more performant, and the other way was creating unnecessary calls. --- actionpack/lib/system_testing/driver_adapter.rb | 11 +++++++++-- actionpack/lib/system_testing/railtie.rb | 4 +++- actionpack/lib/system_testing/test_helper.rb | 5 ----- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/system_testing/driver_adapter.rb b/actionpack/lib/system_testing/driver_adapter.rb index 3958fa4559..47d37a26b7 100644 --- a/actionpack/lib/system_testing/driver_adapter.rb +++ b/actionpack/lib/system_testing/driver_adapter.rb @@ -13,8 +13,15 @@ module SystemTesting @driver ||= DriverAdapters.lookup(default_driver).new end - def driver=(adapter: default_driver, settings: {}) - @driver = DriverAdapters.lookup(adapter).new(settings) + def driver=(adapter) + @driver = case adapter + when Symbol + DriverAdapters.lookup(adapter).new + else + adapter + end + + @driver.call end end end diff --git a/actionpack/lib/system_testing/railtie.rb b/actionpack/lib/system_testing/railtie.rb index f77184ad3d..6c1ddf1448 100644 --- a/actionpack/lib/system_testing/railtie.rb +++ b/actionpack/lib/system_testing/railtie.rb @@ -1,10 +1,12 @@ +require 'system_test_case' + module SystemTesting class Railtie < Rails::Railtie config.system_testing = ActiveSupport::OrderedOptions.new initializer "system_testing.set_configs" do |app| options = app.config.system_testing - options.driver ||= {} + options.driver ||= Rails::SystemTestCase.default_driver ActiveSupport.on_load(:system_testing) do options.each { |k,v| send("#{k}=", v) } diff --git a/actionpack/lib/system_testing/test_helper.rb b/actionpack/lib/system_testing/test_helper.rb index bbf4e469ac..9f2778919c 100644 --- a/actionpack/lib/system_testing/test_helper.rb +++ b/actionpack/lib/system_testing/test_helper.rb @@ -13,11 +13,6 @@ module SystemTesting end end - def before_setup - Base.driver.call - super - end - def after_teardown Capybara.reset_sessions! super -- cgit v1.2.3