capybara-screenshot-diff 1.10.3.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -0
  3. data/CODE_OF_CONDUCT.md +129 -0
  4. data/Rakefile +29 -1
  5. data/capybara-screenshot-diff.gemspec +4 -3
  6. data/docs/RELEASE_PREP.md +42 -0
  7. data/docs/UPGRADING.md +390 -0
  8. data/docs/architecture.md +270 -0
  9. data/docs/ci-integration.md +238 -0
  10. data/docs/configuration.md +395 -0
  11. data/docs/docker-testing.md +24 -0
  12. data/docs/drivers.md +102 -0
  13. data/docs/framework-setup.md +87 -0
  14. data/docs/images/snap_diff_annotated.png +0 -0
  15. data/docs/images/snap_diff_web_ui.png +0 -0
  16. data/docs/migration-guide.md +286 -0
  17. data/docs/organization.md +204 -0
  18. data/docs/reporters.md +46 -0
  19. data/docs/thread_safety.md +97 -0
  20. data/gems.rb +2 -1
  21. data/lib/capybara/screenshot/diff/area_calculator.rb +1 -1
  22. data/lib/capybara/screenshot/diff/browser_helpers.rb +14 -1
  23. data/lib/capybara/screenshot/diff/comparison.rb +3 -0
  24. data/lib/capybara/screenshot/diff/difference.rb +40 -3
  25. data/lib/capybara/screenshot/diff/difference_finder.rb +97 -0
  26. data/lib/capybara/screenshot/diff/drivers/base_driver.rb +4 -0
  27. data/lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb +22 -24
  28. data/lib/capybara/screenshot/diff/drivers/vips_driver.rb +40 -27
  29. data/lib/capybara/screenshot/diff/image_compare.rb +112 -123
  30. data/lib/capybara/screenshot/diff/image_preprocessor.rb +72 -0
  31. data/lib/capybara/screenshot/diff/reporters/default.rb +10 -11
  32. data/lib/capybara/screenshot/diff/screenshot_matcher.rb +77 -36
  33. data/lib/capybara/screenshot/diff/screenshoter.rb +9 -8
  34. data/lib/capybara/screenshot/diff/stable_screenshoter.rb +7 -9
  35. data/lib/capybara/screenshot/diff/vcs.rb +19 -52
  36. data/lib/capybara/screenshot/diff/version.rb +1 -1
  37. data/lib/capybara_screenshot_diff/backtrace_filter.rb +20 -0
  38. data/lib/capybara_screenshot_diff/cucumber.rb +11 -0
  39. data/lib/capybara_screenshot_diff/dsl.rb +123 -7
  40. data/lib/capybara_screenshot_diff/error_with_filtered_backtrace.rb +15 -0
  41. data/lib/capybara_screenshot_diff/minitest.rb +10 -5
  42. data/lib/capybara_screenshot_diff/reporters/html.rb +137 -0
  43. data/lib/capybara_screenshot_diff/reporters/templates/report.html.erb +463 -0
  44. data/lib/capybara_screenshot_diff/rspec.rb +20 -4
  45. data/lib/capybara_screenshot_diff/screenshot_assertion.rb +73 -22
  46. data/lib/capybara_screenshot_diff/screenshot_namer.rb +81 -0
  47. data/lib/capybara_screenshot_diff/snap.rb +14 -3
  48. data/lib/capybara_screenshot_diff/snap_manager.rb +10 -2
  49. data/lib/capybara_screenshot_diff/static.rb +11 -0
  50. data/lib/capybara_screenshot_diff.rb +31 -5
  51. metadata +51 -8
  52. data/lib/capybara/screenshot/diff/test_methods.rb +0 -157
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b731cca6ca98b0d7a9a6c1cb9db02de35b6898cecbb28aba568b8ae773ae0ff
4
- data.tar.gz: d42ae0a773e80fdd6aaf9ae7c6e2b5106131998c650338d24c20f9bc48d90602
3
+ metadata.gz: 5d2139e98f2c24b265a13882b8faf30282f5ef519dcbb77907f5d69d8f565606
4
+ data.tar.gz: 9302c796f95734c4ec4383f926c0aad03630caed8505f1d8fc815fe11bdb3c61
5
5
  SHA512:
6
- metadata.gz: 50bf2196f84506387c16aca897d98e9a5ea4ef9dc1b10216c2473566b001b362afffb1834a843cbdcf83bb35ca33713432dad86bf73cb0cb2a078e3cf2c89e68
7
- data.tar.gz: 69abf40070444fb6a3f2d2d250cb529cdcae957d3c6eefb55ff7e740964f5eae12556ab76b43ccdd9c4b0e14d00366997a7fe4032597bcf41b1a95aeb34471c9
6
+ metadata.gz: b072316d36fe69af44d3f318ba2d24968e9e0b377f85842c9a21d29aeb4ae7375a6b5b02c4842c9f3d9eb3115ed4fbcc33edff6c3b74b8ce788069d2301da95a
7
+ data.tar.gz: 30389f03f593e74c888a2d9de77717f1c839ad8ce41539ef0e6633b5dcff609ed546d7ed5279b3ab7ac9c86c53ed6608872e5b28a70663c7c2aef7c0974fcdf5
data/CHANGELOG.md ADDED
@@ -0,0 +1,77 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [v1.13.0] - 2026-08-22
9
+
10
+ ### Added
11
+ - **`capture_screenshot` DSL method** — take a screenshot without ever comparing or asserting ([#191](https://github.com/snap-diff/snap_diff-capybara/issues/191))
12
+ - **`compare:` option on `screenshot`** — pass `compare: true` (default) to assert, or `compare: false` to capture only ([#191](https://github.com/snap-diff/snap_diff-capybara/issues/191))
13
+ - **`Capybara::Screenshot::Diff.pending_if_new` config** — mark tests as skipped in teardown when a baseline does not exist, complementing `fail_if_new` ([#191](https://github.com/snap-diff/snap_diff-capybara/issues/191))
14
+
15
+ ### Changed
16
+ - **`assert_matches_screenshot` is now the primary assertion method** — captures a screenshot and compares against baseline ([#191](https://github.com/snap-diff/snap_diff-capybara/issues/191))
17
+ - **`screenshot` is now a convenience wrapper** — safe to override in user test classes; the gem no longer calls it internally ([#191](https://github.com/snap-diff/snap_diff-capybara/issues/191))
18
+
19
+ ---
20
+
21
+ ## [v1.12.0] - 2026-04-12
22
+
23
+ ### Added
24
+ - **HTML reporter** — interactive dashboard with 4 comparison modes (both/base/new/heatmap), per-image zoom, keyboard navigation, and search ([#170](https://github.com/snap-diff/snap_diff-capybara/pull/170))
25
+ - **GitHub Actions integration** — inline HTML preview with base64 embedded images + reusable composite action ([#171](https://github.com/snap-diff/snap_diff-capybara/pull/171))
26
+ - **`disable_animations` helper** — inject CSS to stop all animations/transitions during screenshots ([#174](https://github.com/snap-diff/snap_diff-capybara/pull/174))
27
+ - **`snap_diff:clean` rake task** — remove diff artifacts while keeping baselines ([#177](https://github.com/snap-diff/snap_diff-capybara/pull/177))
28
+ - `Diff.compare` for standalone image comparison without Capybara or browser
29
+ - Perceptual color distance (dE00) for anti-aliasing tolerance in VipsDriver
30
+ - `assert_no_screenshot_changes` DSL assertion
31
+ - `Diff.configure` block helper for simplified configuration
32
+ - Ruby 3.5 and 4.0 support
33
+
34
+ ### Changed
35
+ - `blur_active_element` now defaults to `true` — prevents cursor blinking artifacts
36
+ - `hide_caret` now defaults to `true` — stable screenshots without caret
37
+ - `fail_if_new` now defaults to `true` in CI (when `ENV['CI']` is set)
38
+ - Thread-safe reporter notification with mutex ([#175](https://github.com/snap-diff/snap_diff-capybara/pull/175))
39
+
40
+ ### Removed
41
+ - **SVN support** — Git only
42
+ - **ActiveSupport runtime dependency** — pure Ruby, lighter installations
43
+
44
+ ### Fixed
45
+ - VCS path resolution rewritten for thread safety (Open3 + array-form system)
46
+ - Reporter diff artifacts cleaned up properly on `Snap#delete!` ([#173](https://github.com/snap-diff/snap_diff-capybara/pull/173))
47
+ - RSpec matcher now provides `failure_message` and description
48
+ - Missing baseline error includes recording instructions
49
+ - Ruby 4.0 DSLStub ordering compatibility
50
+ - ChunkyPNG `filter_image_with_median` incorrect behavior
51
+ - Tolerance calculation no longer skips large changes
52
+
53
+ ### Performance
54
+ - ChunkyPNG shift-detection: eliminated array allocations (~30% faster for large images)
55
+ - VIPS: cached computations at construction (~15% faster)
56
+ - Memoized region area size, replaced closures with blocks
57
+
58
+ ### Documentation
59
+ - README restructured from 970 to 149 lines with 7 dedicated `docs/` files ([#171](https://github.com/snap-diff/snap_diff-capybara/pull/171))
60
+ - CI integration guide with artifact upload and PR commenting ([docs/ci-integration.md](docs/ci-integration.md))
61
+ - Upgrade guide ([docs/UPGRADING.md](docs/UPGRADING.md))
62
+ - Color comparison guide — tolerance vs perceptual_threshold vs color_distance_limit ([#176](https://github.com/snap-diff/snap_diff-capybara/pull/176))
63
+
64
+ ### Internal
65
+ - Simplified internals: inlined CaptureStrategy, ComparisonLoader, ScreenshotNamerDSL, VipsUtil
66
+ - Unified Screenshoter constructors, consolidated skip_area accessor
67
+ - Upgraded CI dependencies (actions/checkout v5, upload-artifact v7)
68
+
69
+ ---
70
+
71
+ ## [v1.11.0] - Previous Release
72
+
73
+ [Unreleased]: https://github.com/snap-diff/snap_diff-capybara/compare/v1.12.0...HEAD
74
+ [v1.12.0]: https://github.com/snap-diff/snap_diff-capybara/releases/tag/v1.12.0
75
+ [v1.11.0]: https://github.com/snap-diff/snap_diff-capybara/releases/tag/v1.11.0
76
+
77
+ **Upgrade Guide:** See [docs/UPGRADING.md](docs/UPGRADING.md) for detailed migration instructions.
@@ -0,0 +1,129 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement by
63
+ [opening a GitHub Issue](https://github.com/snap-diff/snap_diff-capybara/issues).
64
+
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact:** Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence:** A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact:** A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence:** A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact:** A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence:** A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact:** Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence:** A permanent ban from any sort of public interaction within
114
+ the community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.1, available at
120
+ https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
121
+
122
+ Community Impact Guidelines were inspired by
123
+ [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
124
+
125
+ [homepage]: https://www.contributor-covenant.org
126
+
127
+ For answers to common questions about this code of conduct, see the FAQ at
128
+ https://www.contributor-covenant.org/faq. Translations are available at
129
+ https://www.contributor-covenant.org/translations.
data/Rakefile CHANGED
@@ -11,14 +11,42 @@ Rake::TestTask.new(:test) do |t|
11
11
  t.test_files = FileList["test/**/*_test.rb"]
12
12
  end
13
13
 
14
+ Rake::TestTask.new("test:unit") do |t|
15
+ t.libs << "test"
16
+ t.libs << "lib"
17
+ t.test_files = FileList["test/unit/**/*_test.rb"]
18
+ end
19
+
14
20
  Rake::TestTask.new("test:integration") do |t|
15
21
  t.libs << "test"
16
22
  t.libs << "lib"
17
23
  t.test_files = FileList["test/integration/**/*_test.rb"]
18
24
  end
19
25
 
26
+ desc "Run all tests with coverage"
27
+ task :coverage do
28
+ ENV["COVERAGE"] = "true"
29
+ Rake::Task["test"].invoke
30
+ end
31
+
32
+ desc "Generate sample HTML report. Use bin/rake 'report:sample[embed]' for base64 images"
33
+ task "report:sample", [:embed] do |_t, args|
34
+ embed_arg = args[:embed] ? "--embed" : ""
35
+ ruby "scripts/generate_sample_report.rb #{embed_arg}"
36
+ end
37
+
38
+ desc "Remove screenshot diff artifacts (keeps baselines)"
39
+ task "snap_diff:clean" do
40
+ patterns = ["**/*.diff.png", "**/*.base.png", "**/*.base.diff.png", "**/*.heatmap.diff.png",
41
+ "**/*.diff.webp", "**/*.base.webp", "**/*.base.diff.webp", "**/*.heatmap.diff.webp",
42
+ "**/snap_diff_report.html"]
43
+ removed = patterns.flat_map { |p| Dir.glob("tmp/#{p}") + Dir.glob("doc/screenshots/#{p}") }.uniq
44
+ removed.each { |f| FileUtils.rm_f(f) }
45
+ puts "Removed #{removed.size} diff artifacts"
46
+ end
47
+
20
48
  task "clobber" do
21
- puts "Cleanup tmp/*.png"
49
+ puts "Cleanup tmp/"
22
50
  FileUtils.rm_rf(Dir["./tmp/*"])
23
51
  end
24
52
 
@@ -11,8 +11,8 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["uwe@kubosch.no"]
12
12
  spec.summary = "Track your GUI changes with diff assertions"
13
13
  spec.description = "Save screen shots and track changes with graphical diff"
14
- spec.homepage = "https://github.com/donv/capybara-screenshot-diff"
15
- spec.required_ruby_version = ">= 3.1"
14
+ spec.homepage = "https://github.com/snap-diff/snap_diff-capybara"
15
+ spec.required_ruby_version = ">= 3.2"
16
16
  spec.license = "MIT"
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_runtime_dependency "actionpack", ">= 7.0", "< 9"
26
+ spec.add_development_dependency "actionpack", ">= 7.1", "< 9"
27
+ spec.add_development_dependency "activesupport", ">= 7.1", "< 9"
27
28
  spec.add_runtime_dependency "capybara", ">= 2", "< 4"
28
29
  end
@@ -0,0 +1,42 @@
1
+ # Release Preparation — v1.13.0
2
+
3
+ ## Summary
4
+
5
+ Issue #191 API decoupling: `assert_matches_screenshot` becomes the primary
6
+ assertion method, plus a capture-only API and opt-in pending-instead-of-pass
7
+ for missing baselines.
8
+
9
+ ## Release Checklist
10
+
11
+ ### Pre-Release
12
+
13
+ - [x] Update version to `1.13.0`
14
+ - [x] Run tests: `bundle exec rake test:unit` (235 runs, 0 failures)
15
+ - [x] Update CHANGELOG.md
16
+
17
+ ### Release (One Click)
18
+
19
+ 1. Push to GitHub
20
+ 2. Go to [Actions → Release](https://github.com/snap-diff/snap_diff-capybara/actions/workflows/release.yml)
21
+ 3. Click **Run workflow**, enter `1.13.0`
22
+ 4. Workflow will: test → tag → publish to RubyGems → create GitHub Release
23
+
24
+ ### Post-Release
25
+
26
+ - [ ] Verify on [RubyGems](https://rubygems.org/gems/capybara-screenshot-diff)
27
+ - [ ] Verify GitHub Release created
28
+
29
+ ## What Changed
30
+
31
+ ### New Features
32
+ - `capture_screenshot` DSL method — capture without comparing or asserting
33
+ - `compare:` option on `screenshot` — `compare: false` captures only
34
+ - `Capybara::Screenshot::Diff.pending_if_new` — mark tests skipped in teardown
35
+ when a screenshot has no committed baseline (Minitest, RSpec, and Cucumber)
36
+
37
+ ### Behavior Changes
38
+ - `assert_matches_screenshot` is now the primary assertion method; `screenshot`
39
+ remains as a convenience wrapper and is safe to override in user test classes —
40
+ the gem no longer calls it internally ([#191](https://github.com/snap-diff/snap_diff-capybara/issues/191))
41
+
42
+ See [CHANGELOG.md](../CHANGELOG.md) for full details.