Skip to content

Commit b8f05f2

Browse files
pftgclaude
andcommitted
fix: remove instance_variable_set hack, use finalize in test
- Replace instance_variable_set(:@ToTal) with real passing assertions - Fix deprecation warning by requiring capybara_screenshot_diff/minitest - Integration test uses reporter.finalize instead of manual render+write Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9b19fca commit b8f05f2

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

scripts/generate_sample_report.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require "bundler/setup"
77
require "active_support/core_ext/object/blank"
88
require "capybara_screenshot_diff"
9+
require "capybara_screenshot_diff/minitest"
910
require "capybara/screenshot/diff"
1011
require "capybara_screenshot_diff/reporters/html"
1112

@@ -31,11 +32,14 @@
3132
CapybaraScreenshotDiff::ScreenshotAssertion.new(pair[:name]).tap { |a| a.compare = compare }
3233
end
3334

34-
reporter.record(assertions)
35-
36-
# Add some "passed" total for realistic stats
37-
reporter.instance_variable_set(:@total, reporter.total + 4)
35+
# Add passing assertions (identical images = no difference)
36+
passing = %w[dashboard settings profile users].map do |name|
37+
compare = Capybara::Screenshot::Diff::ImageCompare.new("#{fixtures}/a.png", "#{fixtures}/a.png")
38+
compare.processed
39+
CapybaraScreenshotDiff::ScreenshotAssertion.new(name).tap { |a| a.compare = compare }
40+
end
3841

42+
reporter.record(assertions + passing)
3943
File.write(output_path, reporter.render)
4044

4145
puts "Generated: #{output_path}"

test/integration/report_screenshot_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_report_annotated_both
5151
def generate_sample_report
5252
reporter = CapybaraScreenshotDiff::Reporters::HTML.new(output_path: @report_path)
5353
reporter.record(build_assertions)
54-
File.write(@report_path, reporter.render)
54+
reporter.finalize
5555
end
5656

5757
def build_assertions

0 commit comments

Comments
 (0)