snap_diff-capybara 2.0.0.alpha1 → 2.0.0.beta1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 544c2e3414e9b616291b0cd0e843e72d1a41652017fc2b966926665285aaf49a
4
- data.tar.gz: b2a226430eaeab196e297efc9c476eb4cf0d192334d1503ba29f330fb9bd81ed
3
+ metadata.gz: a063da3ec86978a0e66baaa0c64692c40f18db15ce66b40cab390df9a90be5a1
4
+ data.tar.gz: c34b6fe46a10353ed94d738832cd9dafca06ef0f7a53b2c678408010198f58d2
5
5
  SHA512:
6
- metadata.gz: 91c3e8fd69a3f7e981f77ef8425ccc231e2b9617868f5278bb74c6865c82d59828ab708f7ecf7e57db0f891338f20704c277e8865e8f8444762ffc1b3929748d
7
- data.tar.gz: 2651d17eaceca6a6b8f5c94136e8e221639ec5cf70d70d9178d9d30a630f5014e5eb240ace31233a45a456cf3918d0e70b324c998e2b4ab3531bac7d7d21ffe0
6
+ metadata.gz: '0828945cb79fbf911727deeac0b4cf868f34b5787c37720bc216a6d893115a2d9486a43284cf3f3467834951d1ae438f969a7ea5e1dcdd8ae387fb2cf9f263b9'
7
+ data.tar.gz: 3fc96895702aac83fa636bf8cfd1ac73953b4049b2629104ccbde592af150f3829c3eda7e73e8912b0342793cbf3e45d07056ffffb68c4f3b5594758406cd932
data/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [v2.0.0.beta1] - 2026-08-22
9
+
10
+ Second prerelease of the 2.0 opt-in experiment (see the v2.0.0.alpha1 notes
11
+ below for the namespace change, deprecation warnings, and caveats). Final
12
+ 2.0.0 remains gated on adopter feedback — [#166](https://github.com/snap-diff/snap_diff-capybara/issues/166).
13
+
14
+ ### Added
15
+ - **Dual gem names** — releases now also publish as
16
+ [`snap_diff-capybara`](https://rubygems.org/gems/snap_diff-capybara):
17
+ identical content and versions under the forward-looking name matching this
18
+ repository (the alpha1 mirror was backfilled). Install either, not both.
19
+ - **Migration guide** — [docs/UPGRADING.md](docs/UPGRADING.md) covers the v2
20
+ namespace move, every renamed constant, silencing, and the alpha caveats
21
+ ([#220](https://github.com/snap-diff/snap_diff-capybara/pull/220))
22
+
23
+ ### Internal
24
+ - Test suite exercises the canonical `SnapDiff` names; legacy names remain
25
+ covered by dedicated forwarding/deprecation tests, and a strict warning
26
+ guard now fails the suite on any accidental legacy-name use
27
+ ([#221](https://github.com/snap-diff/snap_diff-capybara/pull/221))
28
+
29
+ ---
30
+
8
31
  ## [v2.0.0.alpha1] - 2026-08-22
9
32
 
10
33
  **Opt-in experiment prerelease.** RubyGems never installs prereleases by default
data/docs/UPGRADING.md CHANGED
@@ -1,5 +1,232 @@
1
1
  # Upgrading
2
2
 
3
+ ## Upgrading to v2.0 (alpha)
4
+
5
+ ### Overview
6
+
7
+ Version 2.0 introduces a new canonical namespace (`SnapDiff`) for cleaner, more discoverable code. The public DSL remains unchanged — your existing `screenshot` and `assert_matches_screenshot` calls work without modification. This guide covers the optional migration path for settings and the new namespace.
8
+
9
+ **Status:** `2.0.0.alpha1` is an opt-in prerelease. RubyGems never installs prereleases by default resolution — normal `bundle update` keeps you on the 1.x line. The final 2.0.0 ships only after adopter feedback; please report anything surprising on [#166](https://github.com/snap-diff/snap_diff-capybara/issues/166).
10
+
11
+ **Estimated upgrade time:** 5–15 minutes (most users need only the Gemfile pin)
12
+
13
+ **Breaking changes:** None for the DSL; deprecation warnings if you reference legacy constants (suppressible), plus two known alpha caveats (see below)
14
+
15
+ ---
16
+
17
+ ### The Short Version (Most Users)
18
+
19
+ ```ruby
20
+ # In your Gemfile — the exact prerelease version is required to opt in
21
+ gem "capybara-screenshot-diff", "2.0.0.alpha1"
22
+ ```
23
+
24
+ ```bash
25
+ bundle install
26
+ bundle exec rake test
27
+ ```
28
+
29
+ **That's it.** Your existing code works unchanged. The old namespaces (`Capybara::Screenshot::Diff`, `CapybaraScreenshotDiff`) are shimmed with deprecation warnings; the new one (`SnapDiff`) is available if you want to modernize.
30
+
31
+ ---
32
+
33
+ ### What Changed
34
+
35
+ #### 1. New Canonical Namespace: `SnapDiff`
36
+
37
+ The implementation now lives in `lib/snap_diff/` under the `SnapDiff` namespace. Every legacy constant still resolves — lazily, to the *same object* — but emits a one-time-per-constant deprecation warning. The main renames:
38
+
39
+ | Legacy name | v2 canonical name |
40
+ |-------------|-------------------|
41
+ | `Capybara::Screenshot::Diff::ImageCompare` | `SnapDiff::Comparison` |
42
+ | `Capybara::Screenshot::Diff::Difference` | `SnapDiff::ComparisonResult` |
43
+ | `Capybara::Screenshot::Diff::Drivers::BaseDriver` | `SnapDiff::Driver` (now a mixin — see below) |
44
+ | `CapybaraScreenshotDiff::SnapManager` / `::Snap` | `SnapDiff::SnapManager` / `SnapDiff::Snap` |
45
+ | `CapybaraScreenshotDiff::RED_RGBA` / `::ORANGE_RGBA` | `SnapDiff::RED_RGBA` / `SnapDiff::ORANGE_RGBA` |
46
+
47
+ **What stays the same:**
48
+ - `screenshot(name)` — still works
49
+ - `assert_matches_screenshot(name)` — still works, still the recommended form
50
+ - `capture_screenshot(name)` — still works
51
+ - All `compare: false/true` flags and overrides work identically
52
+
53
+ **What's new (optional):**
54
+
55
+ ```ruby
56
+ # Old (still works; constant access now warns once per process)
57
+ Capybara::Screenshot::Diff.compare("baseline.png", "current.png")
58
+ Capybara::Screenshot::Diff.configure { |screenshot, diff| ... }
59
+
60
+ # New (recommended for new code)
61
+ SnapDiff.compare("baseline.png", "current.png")
62
+ SnapDiff.start { |screenshot, diff| ... } # same shape as old configure
63
+ SnapDiff.configure { |config| ... } # consolidated config object
64
+ ```
65
+
66
+ #### 2. Consolidated Configuration: `SnapDiff.config`
67
+
68
+ Instead of scattering settings across `Capybara::Screenshot` and `Capybara::Screenshot::Diff`, v2.0 offers a single `SnapDiff::Config` object. Both the old and new paths read and write the same underlying storage — writes through either are visible through the other.
69
+
70
+ **The DSL never changes.** `screenshot` and `assert_matches_screenshot` work exactly as before.
71
+
72
+ ---
73
+
74
+ ### Settings Migration Table
75
+
76
+ The most commonly-used settings and how to update them:
77
+
78
+ | Setting | v1.x (still works in v2) | v2.0 (recommended) | What it does |
79
+ |---------|----------------------|------------------|------|
80
+ | `blur_active_element` | `Capybara::Screenshot.blur_active_element = true` | `SnapDiff.config.blur_active_element = true` | Hide cursor/focus indicator in screenshots (default: `true`) |
81
+ | `hide_caret` | `Capybara::Screenshot.hide_caret = true` | `SnapDiff.config.hide_caret = true` | Make input caret transparent for stable comparisons (default: `true`) |
82
+ | `tolerance` | `Capybara::Screenshot::Diff.tolerance = 0.0005` | `SnapDiff.config.tolerance = 0.0005` | Pixel-level color difference threshold (higher = less strict) |
83
+ | `save_path` | `Capybara::Screenshot.save_path = "doc/screenshots"` | `SnapDiff.config.save_path = "doc/screenshots"` | Where baseline screenshots are stored |
84
+ | `window_size` | `Capybara::Screenshot.window_size = [1280, 1024]` | `SnapDiff.config.window_size = [1280, 1024]` | Browser viewport size for consistent screenshots |
85
+
86
+ **All 27 settings** from both legacy namespaces are available via `SnapDiff.config.<attr_name>` — see the [Configuration Reference](configuration.md) for the full list. One rename to note: `Capybara::Screenshot.enabled` becomes `SnapDiff.config.screenshot_enabled` (it would otherwise collide with `Capybara::Screenshot::Diff.enabled`, which keeps the bare `enabled` name).
87
+
88
+ ---
89
+
90
+ ### Three Ways to Configure
91
+
92
+ All three are equivalent and use the same underlying storage. Pick the one that fits your style.
93
+
94
+ #### Option 1: Traditional block (v1 shape, still works)
95
+
96
+ ```ruby
97
+ # In test_helper.rb or spec_helper.rb
98
+ Capybara::Screenshot::Diff.configure do |screenshot, diff|
99
+ screenshot.window_size = [1280, 1024]
100
+ screenshot.blur_active_element = false
101
+ diff.tolerance = 0.0005
102
+ diff.driver = :vips
103
+ end
104
+ ```
105
+
106
+ #### Option 2: SnapDiff block with old shape (backward-compatible)
107
+
108
+ ```ruby
109
+ SnapDiff.start do |screenshot, diff|
110
+ screenshot.window_size = [1280, 1024]
111
+ screenshot.blur_active_element = false
112
+ diff.tolerance = 0.0005
113
+ diff.driver = :vips
114
+ end
115
+ ```
116
+
117
+ #### Option 3: Consolidated config (cleanest)
118
+
119
+ ```ruby
120
+ SnapDiff.configure do |config|
121
+ config.window_size = [1280, 1024]
122
+ config.blur_active_element = false
123
+ config.tolerance = 0.0005
124
+ config.driver = :vips
125
+ end
126
+ ```
127
+
128
+ ---
129
+
130
+ ### Prepare Today on v1.x (Zero Risk)
131
+
132
+ You don't have to wait for v2.0 to start using the new namespace. `SnapDiff.compare` and `SnapDiff.start` were added in v1.14; `SnapDiff.config` / `SnapDiff.configure` in v1.15. All of them work on the current 1.x line:
133
+
134
+ ```ruby
135
+ # Works TODAY on v1.15+, zero risk
136
+ SnapDiff.compare("baseline.png", "current.png")
137
+ SnapDiff.start { |screenshot, diff| ... }
138
+ SnapDiff.configure { |config| ... }
139
+ ```
140
+
141
+ This means you can migrate your codebase incrementally **now**, before opting into 2.0.
142
+
143
+ ---
144
+
145
+ ### Deprecation Warnings
146
+
147
+ In v2.0, resolving a legacy *constant* emits one deprecation warning per constant per process:
148
+
149
+ ```
150
+ [snap_diff deprecation] `Capybara::Screenshot::Diff::ImageCompare` is deprecated (constant); use `SnapDiff::Comparison` instead.
151
+ ```
152
+
153
+ **Warnings appear for:** legacy constant access — `Capybara::Screenshot::Diff::ImageCompare`, `::Difference`, `::Drivers`, `CapybaraScreenshotDiff::SnapManager`, etc.
154
+
155
+ **Warnings do NOT appear for:**
156
+ - Requiring the gem: `require "capybara_screenshot_diff/minitest"` etc. is not deprecated
157
+ - The DSL: `screenshot`, `assert_matches_screenshot`, `capture_screenshot` are never deprecated
158
+ - Settings access: `Capybara::Screenshot.blur_active_element`, `Capybara::Screenshot::Diff.tolerance=`, and the `Diff.configure` block stay silent — they remain the canonical storage that `SnapDiff.config` forwards to
159
+ - A few advertised entry-point constants that stay eagerly defined by design: `Capybara::Screenshot::Os`, `CapybaraScreenshotDiff::DSL`, `Capybara::Screenshot::Diff::VERSION`, and the driver leaf classes (`Drivers::VipsDriver`, `Drivers::ChunkyPNGDriver`)
160
+
161
+ Warnings go through `Kernel#warn`, so test suites that hook `Warning.warn` (e.g. raise-on-warning setups) see them like any other Ruby warning.
162
+
163
+ #### Silencing Warnings
164
+
165
+ If warnings appear in a test run and you're not ready to migrate yet:
166
+
167
+ ```ruby
168
+ # In test_helper.rb, before running tests
169
+ SnapDiff.silence_deprecations = true
170
+ ```
171
+
172
+ ```bash
173
+ # Or as an environment variable
174
+ export SNAP_DIFF_SILENCE_DEPRECATIONS=1
175
+ ```
176
+
177
+ ---
178
+
179
+ ### Known Alpha Caveats
180
+
181
+ Two deliberate consequences of the lazy shim design — both flagged for feedback on [#166](https://github.com/snap-diff/snap_diff-capybara/issues/166):
182
+
183
+ 1. **`defined?` / `const_defined?` on lazily-shimmed legacy names returns `false`/`nil`.** The shims resolve via `const_missing`, which those checks never trigger. Feature detection like `defined?(Capybara::Screenshot::Diff::ImageCompare)` must move to the `SnapDiff::` name. Rescuing legacy *error classes* is unaffected — they remain eagerly defined.
184
+
185
+ 2. **Reopening `module Capybara::Screenshot::Diff::Drivers` shadows the shim.** The historical custom-driver monkey-patch pattern defines a fresh, empty `Drivers` module instead of reaching the real one. Define custom drivers under `SnapDiff::Drivers` instead — and note `BaseDriver` is gone as a superclass: `class MyDriver < BaseDriver` becomes `include SnapDiff::Driver` (it's a mixin now).
186
+
187
+ ---
188
+
189
+ ### FAQ
190
+
191
+ #### "My tests pass but I see warnings. Should I worry?"
192
+
193
+ No. Warnings are informational and fully suppressible. They're designed to catch legacy namespace references, not break existing CI. If silence is preferable for now, set `SNAP_DIFF_SILENCE_DEPRECATIONS=1` and migrate at your pace.
194
+
195
+ #### "Does the DSL change at all?"
196
+
197
+ No. `screenshot`, `assert_matches_screenshot`, and `capture_screenshot` are stable and unchanged. All overrides (`:compare`, `:tolerance`, etc.) work identically.
198
+
199
+ #### "Can I mix old and new config in the same suite?"
200
+
201
+ Yes. Both paths write to the same underlying storage:
202
+
203
+ ```ruby
204
+ Capybara::Screenshot::Diff.configure do |screenshot, diff|
205
+ screenshot.window_size = [1280, 1024]
206
+ end
207
+
208
+ SnapDiff.configure do |config|
209
+ config.tolerance = 0.0005 # Same storage, visible to the old path too
210
+ end
211
+ ```
212
+
213
+ #### "What if I need to roll back?"
214
+
215
+ All settings and baselines are compatible with v1.x. Simply pin your Gemfile back to `"~> 1.15"` and `bundle update capybara-screenshot-diff`.
216
+
217
+ ---
218
+
219
+ ### Summary Checklist
220
+
221
+ - [ ] Pin `gem "capybara-screenshot-diff", "2.0.0.alpha1"` in your Gemfile
222
+ - [ ] Run `bundle install`
223
+ - [ ] Run your test suite to verify no regressions
224
+ - [ ] (Optional) Migrate config to the `SnapDiff` namespace
225
+ - [ ] (Optional) Silence deprecation warnings if not ready to migrate
226
+ - [ ] Report anything surprising on [#166](https://github.com/snap-diff/snap_diff-capybara/issues/166)
227
+
228
+ ---
229
+
3
230
  ## Upgrading to v1.13.0
4
231
 
5
232
  ### Overview
data/docs/architecture.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This document describes the internal architecture of `capybara-screenshot-diff` — how screenshots are captured, compared, and reported, and how the components fit together.
4
4
 
5
+ Since the v2 namespace move (ADR-004), the implementation lives in `lib/snap_diff/` under the `SnapDiff` namespace. The old file paths (`lib/capybara/screenshot/diff/`, `lib/capybara_screenshot_diff/`) remain as thin forwarders, and the old constants resolve to the same objects via `lib/snap_diff/legacy_shims.rb` with a one-time deprecation warning. Class names below use the canonical `SnapDiff::` names, with legacy names noted where they differ.
6
+
5
7
  ## Overview
6
8
 
7
9
  ```
@@ -31,7 +33,7 @@ This document describes the internal architecture of `capybara-screenshot-diff`
31
33
 
32
34
 
33
35
  ┌──────────────────────────────────────────┐
34
- ImageCompare (layered comparison)
36
+ SnapDiff::Comparison (layered compare)
35
37
  │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
36
38
  │ │1. Byte │ │2. Pixel │ │3. Region │ │
37
39
  │ │ compare │ │ compare │ │ analyze │ │
@@ -50,7 +52,9 @@ This document describes the internal architecture of `capybara-screenshot-diff`
50
52
 
51
53
  ## Component Breakdown
52
54
 
53
- ### 1. DSL Layer (`lib/capybara_screenshot_diff/dsl.rb`)
55
+ ### 1. DSL Layer (`lib/snap_diff/dsl.rb`)
56
+
57
+ `SnapDiff::DSL` — `CapybaraScreenshotDiff::DSL` remains an eager same-object alias.
54
58
 
55
59
  The entry point for test code. `assert_matches_screenshot` is the primary assertion method (captures and compares). `screenshot` is a convenience wrapper with a `compare:` option — `compare: true` (default) delegates to `assert_matches_screenshot`, while `compare: false` delegates to the new `capture_screenshot` method. `capture_screenshot` takes screenshots without assertions. `assert_no_screenshot_changes` keeps its behavior but now delegates to `assert_matches_screenshot` (that redirect is part of the #191 fix). Users can safely override `screenshot` in their test classes without affecting internal gem flow.
56
60
 
@@ -60,20 +64,20 @@ The entry point for test code. `assert_matches_screenshot` is the primary assert
60
64
  3. Delegates to `ScreenshotMatcher` to capture and prepare comparison
61
65
  4. Creates a `ScreenshotAssertion` — either adds it to the thread-local registry (delayed validation) or validates immediately
62
66
 
63
- ### 2. ScreenshotMatcher (`lib/capybara/screenshot/diff/screenshot_matcher.rb`)
67
+ ### 2. ScreenshotMatcher (`lib/snap_diff/screenshot_matcher.rb`)
64
68
 
65
69
  The orchestrator that coordinates capture and comparison:
66
70
 
67
- 1. **Window size check** — verifies browser window is the expected size
71
+ 1. **Viewport preparation** — `SnapDiff::Capture::Viewport.prepare!` (`lib/snap_diff/capture/viewport.rb`) verifies the browser window is the expected size (raise-only, never resizes); runs once per capture, outside any stability retry loop
68
72
  2. **Area calculation** — resolves crop regions and skip areas (supports CSS selectors and coordinates)
69
73
  3. **Base screenshot checkout** — retrieves the committed baseline from git via `Vcs.checkout_vcs`
70
74
  4. **Capture** — delegates to `Screenshoter` or `StableScreenshoter` depending on `stability_time_limit`
71
- 5. **Comparison** — creates an `ImageCompare` object (lazy — actual comparison happens on first access)
75
+ 5. **Comparison** — creates a `SnapDiff::Comparison` object (lazy — actual comparison happens on first access)
72
76
  6. **Assertion** — returns a `ScreenshotAssertion` with the comparison attached
73
77
 
74
78
  **Key design decision:** The "new" screenshot is taken *first*, then compared against the baseline. This means if no baseline exists (first run), we skip comparison entirely and the test passes.
75
79
 
76
- ### 3. Screenshoter & StableScreenshoter (`lib/capybara/screenshot/diff/screenshoter.rb`, `lib/capybara/screenshot/diff/stable_screenshoter.rb`)
80
+ ### 3. Screenshoter & StableScreenshoter (`lib/snap_diff/screenshoter.rb`, `lib/snap_diff/stable_screenshoter.rb`)
77
81
 
78
82
  **Screenshoter:** The basic capture flow:
79
83
  1. Prepares the page (blur active element, hide caret, disable animations, wait for images)
@@ -86,7 +90,9 @@ The orchestrator that coordinates capture and comparison:
86
90
  3. Returns once two consecutive screenshots are identical
87
91
  4. Fails with `UnstableImage` if timeout (`wait`) is reached, generating annotated attempt images for debugging
88
92
 
89
- ### 4. ImageCompare (`lib/capybara/screenshot/diff/image_compare.rb`)
93
+ ### 4. Comparison (`lib/snap_diff/comparison.rb`)
94
+
95
+ `SnapDiff::Comparison` (legacy name: `ImageCompare`); its result value object is `SnapDiff::ComparisonResult` (`lib/snap_diff/comparison_result.rb`, legacy name: `Difference`).
90
96
 
91
97
  The comparison engine uses a **layered optimization strategy** to balance speed and accuracy:
92
98
 
@@ -100,11 +106,11 @@ The comparison engine uses a **layered optimization strategy** to balance speed
100
106
  - `quick_equal?` is designed for fast rejection — it early-returns as soon as a difference is found
101
107
  - `different?` triggers the full comparison if not already processed
102
108
  - `processed` guarantees the comparison is complete and returns the result with all metadata
103
- - `ImageCompare#analyze_difference` handles the actual pixel analysis, delegating to the driver
109
+ - `Comparison#analyze_difference` handles the actual pixel analysis, delegating to the driver
104
110
 
105
- ### 5. Drivers (`lib/capybara/screenshot/diff/drivers/`)
111
+ ### 5. Drivers (`lib/snap_diff/drivers/`)
106
112
 
107
- Drivers abstract image processing operations. Each driver implements:
113
+ Drivers abstract image processing operations. Shared default behavior lives in the `SnapDiff::Driver` mixin (`lib/snap_diff/driver.rb`) — it replaced the old `Drivers::BaseDriver` superclass, so concrete drivers `include SnapDiff::Driver` instead of inheriting. Each driver implements:
108
114
 
109
115
  | Operation | VipsDriver | ChunkyPNGDriver |
110
116
  |-----------|-----------|-----------------|
@@ -135,7 +141,7 @@ Drivers abstract image processing operations. Each driver implements:
135
141
  3. Extend bottom boundary to cover all differing rows
136
142
  4. Supports shift detection (expensive neighbor pixel search)
137
143
 
138
- ### 7. SnapManager & Snap (`lib/capybara_screenshot_diff/snap_manager.rb`, `lib/capybara_screenshot_diff/snap.rb`)
144
+ ### 7. SnapManager & Snap (`lib/snap_diff/snap_manager.rb`, `lib/snap_diff/snap.rb`)
139
145
 
140
146
  **Snap** represents a single screenshot file with path management:
141
147
  - `path` — the actual screenshot file
@@ -148,11 +154,11 @@ Drivers abstract image processing operations. Each driver implements:
148
154
  - Handles VCS checkout of baselines
149
155
  - Manages file operations (copy, move, cleanup)
150
156
 
151
- ### 8. VCS (`lib/capybara/screenshot/diff/vcs.rb`)
157
+ ### 8. VCS (`lib/snap_diff/vcs.rb`)
152
158
 
153
159
  Handles baseline retrieval from git. Uses `git show HEAD:<path>` to extract the committed version. Supports Git LFS via `git lfs smudge`. Returns `false` if the file doesn't exist in VCS (first-run scenario).
154
160
 
155
- ### 9. Reporters (`lib/capybara/screenshot/diff/reporters/`)
161
+ ### 9. Reporters (`lib/capybara/screenshot/diff/reporters/default.rb`, `lib/snap_diff/reporters/html.rb`)
156
162
 
157
163
  **Default reporter:** Generates annotated diff images:
158
164
  - `image.diff.png` — new screenshot with diff region outlined in red
@@ -167,7 +173,7 @@ Handles baseline retrieval from git. Uses `git show HEAD:<path>` to extract the
167
173
  - Keyboard navigation and shortcuts
168
174
  - Responsive layout for mobile
169
175
 
170
- **Custom reporters:** Implement `record(assertions)` and `finalize` methods, then add to `CapybaraScreenshotDiff.reporters`.
176
+ **Custom reporters:** Implement `record(assertions)` and `finalize` methods, then add to `CapybaraScreenshotDiff.reporters`. The process-global reporter lifecycle (registration, notification, finalization) is owned by `SnapDiff::Reporting` (`lib/snap_diff/reporting.rb`); `CapybaraScreenshotDiff.reporters` / `.finalize_reporters!` are thin public shims over it.
171
177
 
172
178
  ### 10. Assertion Lifecycle
173
179
 
@@ -208,7 +214,7 @@ Test begins
208
214
 
209
215
  ### 12. Configuration System
210
216
 
211
- Configuration uses Ruby's `mattr_accessor` (from ActiveSupport, or pure Ruby fallback) and is organized into two namespaces:
217
+ Configuration uses Ruby's `mattr_accessor` (pure Ruby implementation in `lib/capybara/screenshot/diff/config_legacy.rb`, deliberately kept at the old path as the single source of truth for settings storage) and is organized into two namespaces:
212
218
 
213
219
  **`Capybara::Screenshot`** — capture settings:
214
220
  - `window_size`, `stability_time_limit`, `blur_active_element`, `hide_caret`, `disable_animations`
@@ -219,49 +225,65 @@ Configuration uses Ruby's `mattr_accessor` (from ActiveSupport, or pure Ruby fal
219
225
  - `driver`, `tolerance`, `color_distance_limit`, `perceptual_threshold`, `shift_distance_limit`
220
226
  - `area_size_limit`, `skip_area`, `fail_if_new`, `fail_on_difference`, `delayed`
221
227
 
222
- The `Diff.configure` block helper provides a convenient way to set both namespaces at once.
228
+ The `Diff.configure` block helper provides a convenient way to set both namespaces at once. Since v2, `SnapDiff::Config` (`lib/snap_diff/config.rb`) additionally exposes all 27 settings as one flat object via `SnapDiff.config` / `SnapDiff.configure { |config| ... }` — it holds no state of its own, every accessor forwards to the legacy `mattr_accessor` storage, so both views stay consistent.
223
229
 
224
230
  ## File Layout
225
231
 
226
232
  ```
227
233
  lib/
228
- capybara_screenshot_diff.rb # Core module, mattr_accessor definitions
229
- capybara/screenshot/diff.rb # Convenience require (loads minitest)
230
- capybara_screenshot_diff/
234
+ snap_diff.rb # SnapDiff module: compare/start/configure/config
235
+ snap_diff/ # Canonical implementation (v2)
231
236
  dsl.rb # screenshot(), screenshot_group(), etc.
232
- minitest.rb # Minitest assertions integration
233
- rspec.rb # RSpec matcher integration
234
- cucumber.rb # Cucumber World integration
235
- static.rb # Non-Rails static site serving
236
- snap_manager.rb # Screenshot file management
237
- snap.rb # Single screenshot file abstraction
238
- screenshot_namer.rb # Name/path generation with sections/groups
239
- screenshot_assertion.rb # Assertion + registry objects
240
- attempts_reporter.rb # Debug reporting for unstable captures
241
- error_with_filtered_backtrace.rb # Error with filtered stack
242
- reporters/
243
- html.rb # Interactive HTML report reporter
244
- templates/report.html.erb # HTML report template
245
- capybara/screenshot/diff/
246
- version.rb # VERSION constant
247
- utils.rb # Driver detection
237
+ config.rb # SnapDiff::Config flat view over all 27 settings
238
+ deprecation.rb # Warn-once-per-constant machinery
239
+ legacy_shims.rb # const_missing forwarders for the old namespaces
240
+ comparison.rb # Layered comparison engine (ex-ImageCompare)
241
+ comparison_result.rb # Comparison result value object (ex-Difference)
242
+ driver.rb # SnapDiff::Driver mixin (ex-BaseDriver superclass)
248
243
  drivers.rb # Driver factory
249
244
  drivers/
250
- base_driver.rb # Abstract base driver
251
245
  vips_driver.rb # VIPS image processing
252
246
  chunky_png_driver.rb # ChunkyPNG image processing
247
+ capture/
248
+ viewport.rb # Per-capture viewport preparation seam
253
249
  screenshoter.rb # Basic browser screenshot capture
254
250
  stable_screenshoter.rb # Stability detection wrapper
255
251
  screenshot_matcher.rb # Orchestrator for capture + compare
256
- image_compare.rb # Layered comparison engine
257
- difference.rb # Difference result value object
252
+ screenshot_assertion.rb # Assertion + registry objects
253
+ screenshot_namer.rb # Name/path generation with sections/groups
254
+ snap_manager.rb # Screenshot file management
255
+ snap.rb # Single screenshot file abstraction
256
+ reporting.rb # Process-global reporter lifecycle
257
+ reporters/
258
+ html.rb # Interactive HTML report reporter
259
+ templates/report.html.erb # HTML report template
260
+ annotation_service.rb # Diff-image annotation (RED_RGBA / ORANGE_RGBA)
258
261
  image_preprocessor.rb # Pre-processing (skip areas, median filter)
259
262
  area_calculator.rb # Crop/skip area coordinate resolution
260
- region.rb # Bounding box region value object
261
263
  browser_helpers.rb # DOM manipulation helpers
264
+ attempts_reporter.rb # Debug reporting for unstable captures
265
+ error_with_filtered_backtrace.rb # Error with filtered stack
262
266
  vcs.rb # Git baseline checkout
267
+ utils.rb # Driver detection
263
268
  os.rb # OS detection
264
- cucumber.rb # Deprecated Cucumber entry point
265
- reporters/
266
- default.rb # Default annotated-image reporter
269
+ static.rb # Non-Rails static site serving
270
+ version.rb # Gem version
271
+ integrations/
272
+ minitest.rb # Minitest assertions integration
273
+ rspec.rb # RSpec matcher integration
274
+ cucumber.rb # Cucumber World integration
275
+ capybara_screenshot_diff.rb # Umbrella entry point + error classes
276
+ capybara_screenshot_diff/ # Legacy paths — mostly thin forwarders
277
+ minitest.rb / rspec.rb / cucumber.rb # Legacy entry points (load the full gem)
278
+ screenshot_assertion.rb # CapybaraScreenshotDiff session/reporter shims
279
+ ... # Everything else forwards to snap_diff/
280
+ capybara/screenshot/diff.rb # Convenience require (loads minitest)
281
+ capybara/screenshot/diff/
282
+ config_legacy.rb # mattr_accessor settings storage (source of truth)
283
+ region.rb # Bounding box region value object (top-level Region)
284
+ reporters/default.rb # Default annotated-image reporter
285
+ version.rb # Capybara::Screenshot::Diff::VERSION (gemspec reads it)
286
+ ... # Everything else forwards to snap_diff/
267
287
  ```
288
+
289
+ The legacy `Capybara::Screenshot::Diff::*` and `CapybaraScreenshotDiff::*` constants resolve lazily via `snap_diff/legacy_shims.rb` (`const_missing`), pointing at the same objects with a one-time deprecation warning. See [UPGRADING.md](UPGRADING.md) for the migration guide.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SnapDiff
4
- VERSION = "2.0.0.alpha1"
4
+ VERSION = "2.0.0.beta1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snap_diff-capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha1
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch