mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix screenshot helper to provide correct file name
We only want the file name to include the word `failures` if it failed, not any time the user wants to take a screenshot during a test run.
This commit is contained in:
parent
dbb60ff588
commit
983275eb7c
2 changed files with 15 additions and 3 deletions
|
@ -17,7 +17,7 @@ module ActionDispatch
|
|||
# Takes a screenshot of the current page in the browser if the test
|
||||
# failed.
|
||||
#
|
||||
# +take_screenshot+ is included in <tt>system_test_helper.rb</tt> that is
|
||||
# +take_failed_screenshot+ is included in <tt>system_test_helper.rb</tt> that is
|
||||
# generated with the application. To take screenshots when a test fails
|
||||
# add +take_failed_screenshot+ to the teardown block before clearing
|
||||
# sessions.
|
||||
|
@ -26,8 +26,12 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
private
|
||||
def image_name
|
||||
passed? ? method_name : "failures_#{method_name}"
|
||||
end
|
||||
|
||||
def image_path
|
||||
"tmp/screenshots/failures_#{method_name}.png"
|
||||
"tmp/screenshots/#{image_name}.png"
|
||||
end
|
||||
|
||||
def save_image
|
||||
|
|
|
@ -5,6 +5,14 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
|
|||
test "image path is saved in tmp directory" do
|
||||
new_test = ActionDispatch::SystemTestCase.new("x")
|
||||
|
||||
assert_equal "tmp/screenshots/failures_x.png", new_test.send(:image_path)
|
||||
assert_equal "tmp/screenshots/x.png", new_test.send(:image_path)
|
||||
end
|
||||
|
||||
test "image path includes failures text if test did not pass" do
|
||||
new_test = ActionDispatch::SystemTestCase.new("x")
|
||||
|
||||
new_test.stub :passed?, false do
|
||||
assert_equal "tmp/screenshots/failures_x.png", new_test.send(:image_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue