From 0dc63281da1c7075ce63d8dba62e4230d72bfc2a Mon Sep 17 00:00:00 2001 From: eileencodes Date: Sun, 7 Aug 2016 09:01:16 -0400 Subject: Add configuration option for driver adapter This allows any application to change the driver adapter based on the config settings in the test env. --- actionpack/lib/system_testing/base.rb | 2 ++ actionpack/lib/system_testing/driver_adapter.rb | 6 ++---- actionpack/lib/system_testing/railtie.rb | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 actionpack/lib/system_testing/railtie.rb (limited to 'actionpack/lib/system_testing') diff --git a/actionpack/lib/system_testing/base.rb b/actionpack/lib/system_testing/base.rb index ae4236f97d..770342da82 100644 --- a/actionpack/lib/system_testing/base.rb +++ b/actionpack/lib/system_testing/base.rb @@ -5,5 +5,7 @@ module SystemTesting module Base include TestHelper include DriverAdapter + + ActiveSupport.run_load_hooks(:system_testing, self) end end diff --git a/actionpack/lib/system_testing/driver_adapter.rb b/actionpack/lib/system_testing/driver_adapter.rb index 70c4396323..6d94582395 100644 --- a/actionpack/lib/system_testing/driver_adapter.rb +++ b/actionpack/lib/system_testing/driver_adapter.rb @@ -4,11 +4,9 @@ module SystemTesting module DriverAdapter extend ActiveSupport::Concern - included do - self.driver_adapter = :capybara_rack_test_driver - end - module ClassMethods + attr_accessor :driver_adapter + def driver_adapter=(driver_name_or_class) driver = DriverAdapters.lookup(driver_name_or_class).new driver.call diff --git a/actionpack/lib/system_testing/railtie.rb b/actionpack/lib/system_testing/railtie.rb new file mode 100644 index 0000000000..aa3df29344 --- /dev/null +++ b/actionpack/lib/system_testing/railtie.rb @@ -0,0 +1,14 @@ +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_adapter ||= :capybara_rack_test_driver + + ActiveSupport.on_load(:system_testing) do + options.each { |k,v| send("#{k}=", v) } + end + end + end +end -- cgit v1.2.3