Skip to content

fix: quick wins — Quick Start, error messages, RSpec matcher#167

Merged
pftg merged 5 commits into
masterfrom
fix/todo-quick-wins
Apr 12, 2026
Merged

fix: quick wins — Quick Start, error messages, RSpec matcher#167
pftg merged 5 commits into
masterfrom
fix/todo-quick-wins

Conversation

@pftg

@pftg pftg commented Apr 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • TW1: Add 60-second Quick Start to README top — complete working example before feature list
  • TW2: Add recording instructions to missing baseline error message
  • TW4+TW6: Add failure_message and description to RSpec match_screenshot matcher

Test plan

  • Full suite with CI=true (201 runs, 0 failures)

🤖 Generated with Claude Code

Summary by Sourcery

Improve onboarding, error guidance, and RSpec matcher usability for capybara-screenshot-diff.

Enhancements:

  • Clarify the missing baseline screenshot error message with instructions for recording baselines and allowing new screenshots.
  • Enhance the RSpec match_screenshot matcher with custom failure messaging and description for clearer test output.

Documentation:

  • Add a 60-second Quick Start example to the top of the README with a minimal working Minitest setup.

pftg and others added 3 commits April 12, 2026 04:27
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The matcher description now includes the screenshot name.
Added failure_message and failure_message_when_negated for
proper RSpec matcher protocol.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Complete working example before the feature list — reduces
time-to-first-green from reading the whole README to copying
3 code blocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a 60-second Quick Start example to the README, improves the missing-baseline error message with concrete recording instructions, and enriches the RSpec match_screenshot matcher with better failure messaging/description for clearer test output.

Class diagram for updated RSpec match_screenshot matcher

classDiagram
  class MatchScreenshotMatcher {
    - expected_label String
    - options Hash
    + initialize(expected_label, options)
    + matches?(page)
    + failure_message() String
    + description() String
  }

  class CapybaraScreenshotDiff_RSpecIntegration {
    + match_screenshot(expected_label, options) MatchScreenshotMatcher
  }

  CapybaraScreenshotDiff_RSpecIntegration ..> MatchScreenshotMatcher : creates
Loading

Flow diagram for updated missing-baseline error guidance

flowchart TD
  Start[Start baseline check] --> HasBase[Does baseline screenshot exist?]
  HasBase -->|Yes| Continue[Compare current screenshot with baseline]
  HasBase -->|No| FailIfNew[Is fail_if_new enabled?]
  FailIfNew -->|No| AllowNew[Allow creating new baseline without error]
  FailIfNew -->|Yes| RaiseError[Raise ExpectationNotMet with extended message]
  RaiseError --> Msg1[Show line: No existing screenshot found for path]
  Msg1 --> Msg2[Show line: To record baselines: RECORD_SCREENSHOTS=1 bundle exec rake test]
  Msg2 --> Msg3[Show line: To allow new screenshots: Capybara::Screenshot::Diff.fail_if_new = false]
  Continue --> End[Finish test]
  AllowNew --> End
Loading

File-Level Changes

Change Details Files
Introduce a 60-second Quick Start example at the top of the README to give users a full working setup before the feature list.
  • Add a new Quick Start (60 seconds) section showing Gemfile entry, test helper requires, and a minimal system test using screenshot
  • Explain the baseline behavior on first vs subsequent runs within the example
  • Clarify where screenshots are stored and that they are compared against the committed baseline on each test run
README.md
Improve the missing-baseline error message to guide users on how to record screenshots or relax strictness.
  • Extend the check_base_screenshot error string to include RECORD_SCREENSHOTS=1 bundle exec rake test as the way to create baselines
  • Document Capybara::Screenshot::Diff.fail_if_new = false as an option to allow new screenshots instead of raising
lib/capybara/screenshot/diff/screenshot_matcher.rb
Enhance the RSpec match_screenshot matcher with explicit failure messaging and description for clearer test output.
  • Define or update failure_message to surface the underlying screenshot diff failure details in RSpec expectations
  • Define or update description so RSpec outputs a meaningful matcher description in failure reports and documentation tools
lib/capybara_screenshot_diff/rspec.rb

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@pftg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 30 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 30 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 709adf54-b3d1-4434-9b47-5b53b69eef8c

📥 Commits

Reviewing files that changed from the base of the PR and between a960612 and 1e52365.

📒 Files selected for processing (3)
  • README.md
  • lib/capybara/screenshot/diff/screenshot_matcher.rb
  • lib/capybara_screenshot_diff/rspec.rb
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/todo-quick-wins

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new error message hardcodes RECORD_SCREENSHOTS=1 bundle exec rake test, which may not match projects using different test runners (e.g., RSpec or custom commands); consider phrasing it more generically or mentioning alternatives (e.g., RECORD_SCREENSHOTS=1 <your test command>).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new error message hardcodes `RECORD_SCREENSHOTS=1 bundle exec rake test`, which may not match projects using different test runners (e.g., RSpec or custom commands); consider phrasing it more generically or mentioning alternatives (e.g., `RECORD_SCREENSHOTS=1 <your test command>`).

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

pftg and others added 2 commits April 12, 2026 04:30
Helps users know which settings to reach for at each stage
instead of reading all 24 options upfront.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers: missing baselines, CI vs local differences, animations,
dynamic content, and silent assertion skipping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pftg pftg merged commit ac6d4e0 into master Apr 12, 2026
7 checks passed
@pftg pftg deleted the fix/todo-quick-wins branch April 12, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant