diff options
author | eileencodes <eileencodes@gmail.com> | 2016-08-27 10:57:08 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2017-02-20 15:07:32 -0500 |
commit | 9edc998d2a5dcaa5898c11bef29c97403941cff5 (patch) | |
tree | dd6fef163b9fb6c6768628adfe4bfef0d1fba8f0 /actionpack | |
parent | fa2b7b03cc82bb40c76c37c91e4663de3ec0a77f (diff) | |
download | rails-9edc998d2a5dcaa5898c11bef29c97403941cff5.tar.gz rails-9edc998d2a5dcaa5898c11bef29c97403941cff5.tar.bz2 rails-9edc998d2a5dcaa5898c11bef29c97403941cff5.zip |
Refactor driver adapter getter/setter
This makes it easier to ask the system test what driver adapter it is
currently using, and makes it easier to change that setting when
necessary.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/system_testing/driver_adapter.rb | 13 | ||||
-rw-r--r-- | actionpack/lib/system_testing/railtie.rb | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/lib/system_testing/driver_adapter.rb b/actionpack/lib/system_testing/driver_adapter.rb index 6d94582395..3958fa4559 100644 --- a/actionpack/lib/system_testing/driver_adapter.rb +++ b/actionpack/lib/system_testing/driver_adapter.rb @@ -5,11 +5,16 @@ module SystemTesting extend ActiveSupport::Concern module ClassMethods - attr_accessor :driver_adapter + def default_driver + :capybara_rack_test_driver + end + + def driver + @driver ||= DriverAdapters.lookup(default_driver).new + end - def driver_adapter=(driver_name_or_class) - driver = DriverAdapters.lookup(driver_name_or_class).new - driver.call + def driver=(adapter: default_driver, settings: {}) + @driver = DriverAdapters.lookup(adapter).new(settings) end end end diff --git a/actionpack/lib/system_testing/railtie.rb b/actionpack/lib/system_testing/railtie.rb index aa3df29344..f77184ad3d 100644 --- a/actionpack/lib/system_testing/railtie.rb +++ b/actionpack/lib/system_testing/railtie.rb @@ -4,7 +4,7 @@ module SystemTesting initializer "system_testing.set_configs" do |app| options = app.config.system_testing - options.driver_adapter ||= :capybara_rack_test_driver + options.driver ||= {} ActiveSupport.on_load(:system_testing) do options.each { |k,v| send("#{k}=", v) } |