Permalink
Browse files

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.
  • Loading branch information...
eileencodes committed Aug 27, 2016
1 parent fa2b7b0 commit 9edc998d2a5dcaa5898c11bef29c97403941cff5
Showing with 10 additions and 5 deletions.
  1. +9 −4 actionpack/lib/system_testing/driver_adapter.rb
  2. +1 −1 actionpack/lib/system_testing/railtie.rb
@@ -5,11 +5,16 @@ module DriverAdapter
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
@@ -4,7 +4,7 @@ class Railtie < Rails::Railtie
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) }

0 comments on commit 9edc998

Please sign in to comment.