Class: Guardrails::VisualDiff::SnapDiff
- Inherits:
-
Object
- Object
- Guardrails::VisualDiff::SnapDiff
- Defined in:
- lib/guardrails/visual_diff/snap_diff.rb
Overview
Adapter for snap_diff-capybara (formerly capybara-screenshot-diff). The gem commits baselines to git under ‘doc/screenshots/` by convention. After a failed run there’s a ‘<name>.diff.png` sibling next to `<name>.png`. Walking the directory tree and pairing names gives us a binary pass/fail per scenario without needing snap_diff to emit a JSON report (see upstream issue — TODO: link once filed).
Limits:
-
No mismatch percentage; snap_diff is binary at the filesystem level. Findings emit ‘mismatch_ratio: nil` and VisualDiff treats nil as “unconditionally failing” (any diff fails).
-
No URL / viewport / selector — those live in snap_diff’s Capybara tests, not the artifact tree. Adapters that have them (BackstopJS, issue #15) populate the optional fields.
Constant Summary collapse
- DIFF_SUFFIX =
".diff.png"- HEATMAP_SUFFIX =
".heatmap.diff.png"
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(root:, dir:) ⇒ SnapDiff
constructor
A new instance of SnapDiff.
Constructor Details
Instance Method Details
#collect ⇒ Object
30 31 32 33 34 |
# File 'lib/guardrails/visual_diff/snap_diff.rb', line 30 def collect return [] unless @dir.directory? diff_files.map { |diff| build_finding(diff) }.compact end |