Skip to content

Commit 1728b00

Browse files
pftgclaude
andcommitted
fix: address multi-agent journey review findings
Critical: - at_exit output_path access moved into finalize (no crash on custom reporters) - at_exit registered inside unless guard (no double registration) - README Quick Start adds include modules (was missing, NoMethodError) - relative_path uses expand_path to handle absolute vs relative paths High: - matrix-screenshot-driver: always() → failure() (no artifact noise on pass) - README "What You Get" clarifies .base.png is runtime copy, not baseline Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 116593d commit 1728b00

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ jobs:
218218
SCREENSHOT_DRIVER: ${{ matrix.screenshot-driver }}
219219

220220
- uses: ./.github/actions/upload-screenshots
221-
if: always()
221+
if: failure()
222222
with:
223223
name: screenshots-${{ matrix.capybara-driver }}-${{ matrix.screenshot-driver }}
224224

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ require 'capybara_screenshot_diff/minitest'
1919
```
2020

2121
```ruby
22-
# test/system/homepage_test.rb
23-
class HomepageTest < ActionDispatch::SystemTestCase
22+
# test/application_system_test_case.rb (or test/system/homepage_test.rb)
23+
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
24+
include CapybaraScreenshotDiff::DSL
25+
include CapybaraScreenshotDiff::Minitest::Assertions
26+
end
27+
28+
class HomepageTest < ApplicationSystemTestCase
2429
test "homepage" do
2530
visit "/"
2631
screenshot "homepage" # First run: saves baseline. Next runs: compares.
@@ -42,8 +47,8 @@ When a screenshot differs, you get:
4247

4348
| File | Description |
4449
|------|-------------|
45-
| `homepage.png` | Current screenshot |
46-
| `homepage.base.png` | Committed baseline |
50+
| `homepage.png` | Committed baseline (in version control) |
51+
| `homepage.base.png` | Runtime copy of baseline (for comparison) |
4752
| `homepage.diff.png` | Visual diff with changes highlighted in red |
4853
| `homepage.heatmap.diff.png` | Heatmap of pixel differences |
4954

lib/capybara_screenshot_diff/reporters/html.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def finalize
4343
end
4444

4545
write_report
46-
true
46+
output_path
4747
end
4848

4949
def passed = total - failures.size
@@ -82,10 +82,10 @@ def failure_entry_for(name, compare)
8282
def relative_path(path)
8383
return unless path
8484

85-
pathname = Pathname.new(path)
85+
pathname = Pathname.new(path).expand_path
8686
return unless pathname.exist?
8787

88-
pathname.relative_path_from(@report_dir).to_s
88+
pathname.relative_path_from(@report_dir.expand_path).to_s
8989
end
9090

9191
def write_report
@@ -98,13 +98,13 @@ def write_report
9898

9999
unless CapybaraScreenshotDiff.reporters.any?(CapybaraScreenshotDiff::Reporters::HTML)
100100
CapybaraScreenshotDiff.reporters << CapybaraScreenshotDiff::Reporters::HTML.new
101-
end
102101

103-
at_exit do
104-
CapybaraScreenshotDiff.reporters.each do |reporter|
105-
wrote = reporter.finalize
106-
$stdout.puts "[snap_diff] HTML report: #{reporter.output_path}" if wrote
107-
rescue => e
108-
warn "[snap_diff] Reporter #{reporter.class} failed (#{e.class}: #{e.message})" if ENV["DEBUG"]
102+
at_exit do
103+
CapybaraScreenshotDiff.reporters.each do |reporter|
104+
result = reporter.finalize
105+
$stdout.puts "[snap_diff] HTML report: #{result}" if result.is_a?(Pathname)
106+
rescue => e
107+
warn "[snap_diff] Reporter #{reporter.class} failed (#{e.class}: #{e.message})" if ENV["DEBUG"]
108+
end
109109
end
110110
end

0 commit comments

Comments
 (0)