Skip to content

Commit

Permalink
Move screenshot clearing to be before error raise (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorBrysonRouse authored Nov 30, 2023
1 parent fe828ad commit 7a81562
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/capybara/screenshot/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ def self.included(klass)

klass.teardown do
if Screenshot.active? && @test_screenshots.present?
track_failures(@test_screenshots)
@test_screenshots.clear
begin
track_failures(@test_screenshots)
ensure
@test_screenshots.clear
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/capybara/screenshot/diff_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def _test_sample_screenshot_error

@test_screenshots = []
@test_screenshots << ["my_test.rb:42", "sample_screenshot", mock]
mock.expect(:clear_screenshots, @test_screenshots)
end
end

Expand Down Expand Up @@ -174,6 +175,7 @@ def _test_sample_screenshot_error
expected_message =
"Screenshot does not match for 'sample_screenshot' expected error message for non minitest"
assert_raises(RuntimeError, expected_message) { test_case.teardown }
assert(test_case.instance_variable_get(:@test_screenshots).empty?)
end
end
end
Expand Down

0 comments on commit 7a81562

Please sign in to comment.