Skip to content

Commit d71fede

Browse files
pftgclaude
andcommitted
fix: review round 3 — init @Finalized, vips driver, path existence check
- Initialize @Finalized = false explicitly in constructor - Integration test uses driver: :vips for heatmap generation - Assign @report_path before skip so teardown never gets nil - relative_path checks file existence to avoid broken image links when annotation files don't exist (e.g. dimension mismatches) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3cc3d84 commit d71fede

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

lib/capybara_screenshot_diff/reporters/html.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def initialize(output_path: "tmp/snap_diff-report/index.html")
1515
@report_dir = @output_path.dirname
1616
@failures = []
1717
@total = 0
18+
@finalized = false
1819
end
1920

2021
def record(assertions)
@@ -75,7 +76,10 @@ def failure_entry_for(name, compare)
7576
def relative_path(path)
7677
return unless path
7778

78-
Pathname.new(path).relative_path_from(@report_dir).to_s
79+
pathname = Pathname.new(path)
80+
return unless pathname.exist?
81+
82+
pathname.relative_path_from(@report_dir).to_s
7983
end
8084

8185
def write_report

test/integration/report_screenshot_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ class ReportScreenshotTest < SystemTestCase
77
PERCEPTUAL_THRESHOLD = 2.0
88

99
setup do
10-
skip "Run with RECORD_SCREENSHOTS=1 to update report fixtures" unless ENV["RECORD_SCREENSHOTS"]
1110
@report_path = Pathname.new("test/fixtures/app/sample_report.html")
11+
skip "Run with RECORD_SCREENSHOTS=1 to update report fixtures" unless ENV["RECORD_SCREENSHOTS"]
1212
generate_sample_report
1313
visit "/sample_report.html"
1414
end
1515

1616
teardown do
17-
FileUtils.rm_f(@report_path) if @report_path
17+
FileUtils.rm_f(@report_path)
1818
end
1919

2020
def test_report_both_view
@@ -58,7 +58,7 @@ def build_assertions
5858
end
5959

6060
def build_assertion(name, base_path, new_path)
61-
compare = Capybara::Screenshot::Diff::ImageCompare.new(new_path, base_path)
61+
compare = Capybara::Screenshot::Diff::ImageCompare.new(new_path, base_path, driver: :vips)
6262
compare.processed
6363
CapybaraScreenshotDiff::ScreenshotAssertion.new(name).tap { |a| a.compare = compare }
6464
end

0 commit comments

Comments
 (0)