From 3f414c22c70d5647d2ee9f16f7e4eec15c829afb Mon Sep 17 00:00:00 2001 From: eileencodes Date: Sat, 3 Dec 2016 09:27:44 -0500 Subject: Cleanup Rails provided helpers 1. Clean up screenshot helper Updates documentation to be clearer and separates the concerns of saving the image, setting the image path, and displaying the image. 2. Remove Rails provided assertions for selectors This was moved upstream to Capybara and is no longer necessary to be included in Rails 3. Remove form helper The form helper is pretty specific to Basecamp's needs and may not be helpful outside of Rails. --- .../test_helpers/screenshot_helper.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'actionsystemtest/lib/action_system_test/test_helpers/screenshot_helper.rb') 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 1b198b9b29..d4d0d79e95 100644 --- a/actionsystemtest/lib/action_system_test/test_helpers/screenshot_helper.rb +++ b/actionsystemtest/lib/action_system_test/test_helpers/screenshot_helper.rb @@ -13,24 +13,32 @@ module ActionSystemTest # ActionSystemTest.driver.supports_screenshots? # => true def take_screenshot + save_image puts "[Screenshot]: #{image_path}" - puts find_image + puts display_image end - # Takes a screenshot only if the test failed. This is included - # by default in +teardown+ of system test. + # Takes a screenshot of the current page in the browser if the test + # failed. + # + # +take_screenshot+ is included in system_test_helper.rb that is + # generated with the application. To take screenshots when a test fails + # add +take_failed_screenshot+ to the teardown block before clearing any + # sessions. 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)) - path + "tmp/screenshots/failures_#{method_name}.png" + end + + def save_image + page.save_screenshot(Rails.root.join(image_path)) end - def find_image + def display_image if ENV["CAPYBARA_INLINE_SCREENSHOT"] == "artifact" "\e]1338;url=artifact://#{image_path}\a" else -- cgit v1.2.3