aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2017-08-27 15:14:49 -0400
committerGitHub <noreply@github.com>2017-08-27 15:14:49 -0400
commit4d7436f0aa571794b62be12b90b10e7b1646df90 (patch)
tree053b1b1209191c64d791cbf94c2881fe2c2c52e9 /actionpack/lib
parent62647ce417f2e28d0a40368857b209e69208fdaf (diff)
parent52422f2af60c0830da6e5749700f911c6c0b22ea (diff)
downloadrails-4d7436f0aa571794b62be12b90b10e7b1646df90.tar.gz
rails-4d7436f0aa571794b62be12b90b10e7b1646df90.tar.bz2
rails-4d7436f0aa571794b62be12b90b10e7b1646df90.zip
Merge pull request #30421 from y-yagi/fix_30405
Retrive screenshot in relative path of current directory
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
index 7efdeb4e7b..6c337cdc31 100644
--- a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
+++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
@@ -44,11 +44,15 @@ module ActionDispatch
end
def image_path
- "tmp/screenshots/#{image_name}.png"
+ @image_path ||= absolute_image_path.relative_path_from(Pathname.pwd).to_s
+ end
+
+ def absolute_image_path
+ Rails.root.join("tmp/screenshots/#{image_name}.png")
end
def save_image
- page.save_screenshot(Rails.root.join(image_path))
+ page.save_screenshot(absolute_image_path)
end
def output_type
@@ -69,10 +73,10 @@ module ActionDispatch
case output_type
when "artifact"
- message << "\e]1338;url=artifact://#{image_path}\a\n"
+ message << "\e]1338;url=artifact://#{absolute_image_path}\a\n"
when "inline"
- name = inline_base64(File.basename(image_path))
- image = inline_base64(File.read(image_path))
+ name = inline_base64(File.basename(absolute_image_path))
+ image = inline_base64(File.read(absolute_image_path))
message << "\e]1337;File=name=#{name};height=400px;inline=1:#{image}\a\n"
end