diff options
author | eileencodes <eileencodes@gmail.com> | 2016-11-12 09:49:28 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2017-02-20 15:07:33 -0500 |
commit | 84f82f0a84de0906d195b529a9f780141c43507a (patch) | |
tree | f2919614c9ce8f0adccdfd83e47d43f6484d17bc /actionsystemtest/lib/action_system_test | |
parent | 1db7a5c285eeb61acc998c0c27788a61bd948d5c (diff) | |
download | rails-84f82f0a84de0906d195b529a9f780141c43507a.tar.gz rails-84f82f0a84de0906d195b529a9f780141c43507a.tar.bz2 rails-84f82f0a84de0906d195b529a9f780141c43507a.zip |
Refactor config settings to use generated file
Originally I had set up system testing to have one configuration option
to be set in the test environment. After thinking it over I think a
generated class on app creation would be best. The reason for this is
Capybara has a ton of configuration options that I'm sure some folks
want to use.
Thinking about how we handle screenshots, database transactions, and a
whole bunch of other settings it would be better for users to be able to
turn all of that on and off.
When an app or scaffold is generated a `test/system_test_helper.rb` test
helper will be generated as well. This will contain the class for tests
to inherit from `ActionSystemTestCase` which will inherit from
`ActionSystemTest::Base`. Here is where users can change the test
driver, remove the screenshot helper, and add their additional Capybara
configuration.
Diffstat (limited to 'actionsystemtest/lib/action_system_test')
3 files changed, 5 insertions, 10 deletions
diff --git a/actionsystemtest/lib/action_system_test/driver_adapter.rb b/actionsystemtest/lib/action_system_test/driver_adapter.rb index fe12ecaf80..892edd2d32 100644 --- a/actionsystemtest/lib/action_system_test/driver_adapter.rb +++ b/actionsystemtest/lib/action_system_test/driver_adapter.rb @@ -9,15 +9,11 @@ module ActionSystemTest extend ActiveSupport::Concern module ClassMethods - def default_driver # :nodoc - :rails_selenium_driver - end - # Returns the current driver that is set. If no driver is set in the # Rails' configuration file then +:rails_selenium_driver+ will be # initialized. def driver - @driver ||= DriverAdapters.lookup(default_driver) + @driver ||= DriverAdapters.lookup(DEFAULT_DRIVER) end # Specify the adapter and settings for the system test driver set in the diff --git a/actionsystemtest/lib/action_system_test/test_helper.rb b/actionsystemtest/lib/action_system_test/test_helper.rb index 428f0faeca..c9389b83ec 100644 --- a/actionsystemtest/lib/action_system_test/test_helper.rb +++ b/actionsystemtest/lib/action_system_test/test_helper.rb @@ -15,7 +15,6 @@ module ActionSystemTest end def after_teardown - take_screenshot if supported? Capybara.reset_sessions! super end diff --git a/actionsystemtest/lib/action_system_test/test_helpers/screenshot_helper.rb b/actionsystemtest/lib/action_system_test/test_helpers/screenshot_helper.rb index 37336e976f..3264ddc86e 100644 --- a/actionsystemtest/lib/action_system_test/test_helpers/screenshot_helper.rb +++ b/actionsystemtest/lib/action_system_test/test_helpers/screenshot_helper.rb @@ -18,11 +18,11 @@ module ActionSystemTest puts find_image end - private - def supported? - ActionSystemTest.driver.supports_screenshots? && !passed? - end + def take_failed_screenshot + take_screenshot unless passed? + end + private def image_path path = "tmp/screenshots/failures_#{method_name}.png" page.save_screenshot(Rails.root.join(path)) |