diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2017-08-27 15:14:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-27 15:14:49 -0400 |
commit | 4d7436f0aa571794b62be12b90b10e7b1646df90 (patch) | |
tree | 053b1b1209191c64d791cbf94c2881fe2c2c52e9 /actionpack/test | |
parent | 62647ce417f2e28d0a40368857b209e69208fdaf (diff) | |
parent | 52422f2af60c0830da6e5749700f911c6c0b22ea (diff) | |
download | rails-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/test')
-rw-r--r-- | actionpack/test/dispatch/system_testing/screenshot_helper_test.rb | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb index 4b49a42317..2afda31cf5 100644 --- a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb +++ b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb @@ -8,23 +8,29 @@ class ScreenshotHelperTest < ActiveSupport::TestCase test "image path is saved in tmp directory" do new_test = DrivenBySeleniumWithChrome.new("x") - assert_equal "tmp/screenshots/x.png", new_test.send(:image_path) + Rails.stub :root, Pathname.getwd do + assert_equal "tmp/screenshots/x.png", new_test.send(:image_path) + end end test "image path includes failures text if test did not pass" do new_test = DrivenBySeleniumWithChrome.new("x") - new_test.stub :passed?, false do - assert_equal "tmp/screenshots/failures_x.png", new_test.send(:image_path) + Rails.stub :root, Pathname.getwd do + new_test.stub :passed?, false do + assert_equal "tmp/screenshots/failures_x.png", new_test.send(:image_path) + end end end test "image path does not include failures text if test skipped" do new_test = DrivenBySeleniumWithChrome.new("x") - new_test.stub :passed?, false do - new_test.stub :skipped?, true do - assert_equal "tmp/screenshots/x.png", new_test.send(:image_path) + Rails.stub :root, Pathname.getwd do + new_test.stub :passed?, false do + new_test.stub :skipped?, true do + assert_equal "tmp/screenshots/x.png", new_test.send(:image_path) + end end end end @@ -36,13 +42,23 @@ class ScreenshotHelperTest < ActiveSupport::TestCase new_test = DrivenBySeleniumWithChrome.new("x") - new_test.stub :passed?, false do - assert_match "\e]1338;url=artifact://tmp/screenshots/failures_x.png\a", new_test.send(:display_image) + Rails.stub :root, Pathname.getwd do + new_test.stub :passed?, false do + assert_match %r|url=artifact://.+?tmp/screenshots/failures_x\.png|, new_test.send(:display_image) + end end ensure ENV["RAILS_SYSTEM_TESTING_SCREENSHOT"] = original_output_type end end + + test "image path returns the relative path from current directory" do + new_test = DrivenBySeleniumWithChrome.new("x") + + Rails.stub :root, Pathname.getwd.join("..") do + assert_equal "../tmp/screenshots/x.png", new_test.send(:image_path) + end + end end class RackTestScreenshotsTest < DrivenByRackTest |