feat: add Diff.configure helper, CI defaults, and Quick Setup docs#158
Conversation
New screenshots are now automatically rejected in CI (when ENV['CI'] is present), matching the pattern every downstream project uses. Can still be overridden with explicit `fail_if_new = false`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces 50-line setup files with a clean block:
Capybara::Screenshot::Diff.configure do |screenshot, diff|
screenshot.window_size = [1280, 1024]
diff.driver = :vips
diff.tolerance = 0.0005
end
Yields Screenshot and Diff modules directly — no new config object,
no breaking changes, works with all existing mattr_accessors.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Document Diff.configure block helper with full example - Add recommended tolerance values table per driver and use case - Note that fail_if_new auto-detects CI environments - Clarify that enabled=false is sufficient (no no-op monkey-patching needed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reviewer's GuideIntroduces a new Capybara::Screenshot::Diff.configure helper for centralized configuration, changes the default fail_if_new behavior to depend on the CI environment variable, and updates the README with a Quick Setup section and recommended tolerance settings documentation. Sequence diagram for CI-dependent fail_if_new behavior during visual diffsequenceDiagram
title Visual diff run with CI dependent fail_if_new
actor Developer
participant TestRunner
participant Capybara_Screenshot_Diff as Capybara_Screenshot_Diff
participant Env as ENV
Developer->>TestRunner: run test suite
TestRunner->>Capybara_Screenshot_Diff: initialize configuration
Capybara_Screenshot_Diff->>Env: read CI
alt CI set
Env-->>Capybara_Screenshot_Diff: CI=present
Capybara_Screenshot_Diff-->>Capybara_Screenshot_Diff: fail_if_new = true
else CI not set
Env-->>Capybara_Screenshot_Diff: CI=nil
Capybara_Screenshot_Diff-->>Capybara_Screenshot_Diff: fail_if_new = false
end
TestRunner->>Capybara_Screenshot_Diff: compare screenshot
alt new screenshot created
Capybara_Screenshot_Diff-->>TestRunner: raise failure if fail_if_new
else existing screenshot
Capybara_Screenshot_Diff-->>TestRunner: proceed normally
end
Class diagram for Capybara::Screenshot::Diff configure helper and fail_if_new defaultclassDiagram
class Capybara
class Capybara_Screenshot
class Capybara_Screenshot_Diff {
<<module>>
+Boolean delayed
+Integer area_size_limit
+Boolean fail_if_new
+Boolean fail_on_difference
+Integer color_distance_limit
+Boolean enabled
+Symbol driver
+Float tolerance
+Hash default_options()
+void configure(screenshot, diff)
}
class Capybara_Screenshot_Screenshot {
<<module>>
+Array window_size
+Integer stability_time_limit
+Boolean blur_active_element
+Boolean hide_caret
}
Capybara o-- Capybara_Screenshot
Capybara_Screenshot o-- Capybara_Screenshot_Diff
Capybara_Screenshot o-- Capybara_Screenshot_Screenshot
%% configure yields these two modules
Capybara_Screenshot_Diff ..> Capybara_Screenshot_Screenshot : yields_in_configure
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe pull request enhances configuration capabilities and CI-aware behavior for the Capybara screenshot diff library. It introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Tests create new screenshots without baselines, so fail_if_new must be false during test runs. The new CI-aware default (ENV['CI']) would otherwise break all tests that capture new screenshots. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
db9f5bd to
923d1f6
Compare
Summary
Capybara::Screenshot::Diff.configureblock helper — replaces 50-line setup files with a clean 10-line blockfail_if_newtoENV['CI'].present?— zero-config CI behavior matching every downstream project's patternenabled = falseis sufficient (no need for no-op monkey-patching)Usage
Test plan
🤖 Generated with Claude Code
Summary by Sourcery
Introduce a top-level configuration helper for Capybara::Screenshot::Diff and document recommended defaults for common visual testing setups.
New Features:
Enhancements:
Documentation:
Summary by CodeRabbit
Release Notes
Documentation
New Features