Permalink
Browse files

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.
  • Loading branch information...
eileencodes committed Sep 11, 2016
1 parent d63cfa2 commit 4533bb7dcbdd6e0451395bc869d6c3603c6ff1df
@@ -13,8 +13,15 @@ def driver
@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
@@ -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) }
@@ -13,11 +13,6 @@ module TestHelper
end
end
def before_setup
Base.driver.call
super
end
def after_teardown
Capybara.reset_sessions!
super

0 comments on commit 4533bb7

Please sign in to comment.