Skip to content

refactor: ADR-006 T3+T4 — hoist setup, consolidate assertion helpers#186

Merged
pftg merged 4 commits intomasterfrom
refactor/adr006-test-simplification-t3-t4-t6
Apr 13, 2026
Merged

refactor: ADR-006 T3+T4 — hoist setup, consolidate assertion helpers#186
pftg merged 4 commits intomasterfrom
refactor/adr006-test-simplification-t3-t4-t6

Conversation

@pftg
Copy link
Copy Markdown
Collaborator

@pftg pftg commented Apr 13, 2026

Summary

  • T3: Hoist duplicated setup from 3 nested classes to parent DifferenceFinderTest (−12 lines)
  • T4: Extract assert_driver_check_called(driver, check_type, times) parameterized helper. Old methods kept as one-line aliases for backward compatibility.
  • T6: Skipped — assert_same_images param order already matches Minitest convention

Net: −16 lines, cleaner test structure.

Test plan

  • 224 unit tests pass, 0 failures

🤖 Generated with Claude Code

Summary by Sourcery

Refactor test helpers and difference finder tests to reduce duplication and centralize assertion logic.

Enhancements:

  • Hoist shared driver and path setup from nested DifferenceFinderTest subclasses into the parent test class to simplify test initialization.
  • Consolidate multiple image comparison assertion helpers into a single parameterized driver check assertion while preserving old method names as thin aliases for backward compatibility.

Summary by CodeRabbit

This release contains internal test infrastructure improvements with no user-facing changes.

  • Tests
    • Consolidated several specialized assertion helpers into a single generalized assertion helper while preserving backward-compatible aliases.
    • Simplified test setup by moving shared initialization to a common setup, reducing duplication across nested tests.

T3: Hoist duplicated setup (base_path, new_path, driver, comparison)
from 3 nested classes to parent DifferenceFinderTest. Nested classes
inherit setup and only add their own (@finder).

T4: Extract assert_driver_check_called(driver, check_type, times)
parameterized helper. Old methods kept as one-line aliases.

T6: Skipped — param order already matches Minitest convention.

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

sourcery-ai Bot commented Apr 13, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors test helpers to use a single parameterized assertion for driver checks while preserving old helper names as thin aliases, and hoists duplicated setup logic from nested DifferenceFinderTest subclasses into the parent test class to reduce duplication and centralize test initialization.

File-Level Changes

Change Details Files
Introduce a generic driver check assertion helper and keep existing helpers as aliases for backward compatibility.
  • Replace three specialized assertion methods for dimension, pixel, and difference region checks with a single parameterized assert_driver_check_called helper that uses public_send to access the appropriate *_calls collection on the driver.
  • Update the assertion message to interpolate the check_type and actual call count for clearer failure output.
  • Reintroduce assert_dimension_check_called, assert_pixel_check_called, and assert_difference_region_called as one-line convenience wrappers that delegate to assert_driver_check_called with the appropriate check_type symbol.
test/support/test_helpers.rb
Hoist repeated DifferenceFinder test setup from nested test classes into the parent test class.
  • Add a setup block to the parent DifferenceFinderTest class that initializes @base_path, @new_path, @driver, and calls setup_test_comparison once for all nested tests.
  • Remove the duplicated setup blocks from the InitializationTest, QuickModeTest, and FullModeTest nested classes that previously performed the same initialization work.
  • Keep QuickModeTest and FullModeTest setup blocks focused only on creating @finder via create_finder, relying on the parent setup for common state.
test/unit/difference_finder_test.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
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

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 15 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 15 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: c94803b8-eb71-489d-938e-a396830602ca

📥 Commits

Reviewing files that changed from the base of the PR and between b6a50cc and b944dc6.

📒 Files selected for processing (4)
  • .github/actions/upload-screenshots/action.yml
  • .github/workflows/test.yml
  • README.md
  • docs/ci-integration.md
📝 Walkthrough

Walkthrough

Consolidates three test assertion helpers into a single generalized assert_driver_check_called with alias wrappers, and centralizes shared test initialization from nested setups into a single outer setup in difference_finder_test.rb.

Changes

Cohort / File(s) Summary
Test Assertion Helpers Refactoring
test/support/test_helpers.rb
Added assert_driver_check_called(driver, check_type, times = 1) that resolves #{check_type}_calls via public_send and asserts call count; preserved assert_dimension_check_called, assert_pixel_check_called, and assert_difference_region_called as thin delegating aliases.
Test Setup Consolidation
test/unit/difference_finder_test.rb
Moved common initialization (@base_path, @new_path, @driver, setup_test_comparison) into the outer DifferenceFinderTest setup; nested tests now only create @finder in their own setups.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hopped through tests with a thoughtful twitch,
One helper to call them — compact and rich.
Setups gathered snug in a single embrace,
Less duplication, more tidy space. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: refactoring to hoist setup and consolidate assertion helpers, with reference to specific architectural decision records (ADR-006) and task numbers (T3, T4).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/adr006-test-simplification-t3-t4-t6

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/unit/difference_finder_test.rb`:
- Around line 21-22: The class body for InitializationTest starts with an extra
blank line causing a StandardRB lint failure (Layout/EmptyLinesAroundClassBody);
remove the empty line immediately after the declaration "class
InitializationTest < self" so the first statement in the class follows the class
line directly, ensuring no blank line between the class header and its contents.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 30089cca-91a5-4b6a-92c7-b5a77babcbe8

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7be3b and 59f5035.

📒 Files selected for processing (2)
  • test/support/test_helpers.rb
  • test/unit/difference_finder_test.rb

Comment thread test/unit/difference_finder_test.rb Outdated
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

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:

  • In assert_driver_check_called, consider validating check_type against the supported options before calling public_send so that a typo or unexpected symbol yields a clearer failure than a NoMethodError on the driver.
  • The error message in assert_driver_check_called now interpolates the raw check_type symbol; you might want to normalize or prettify it (e.g., dimension check instead of dimension_check) to keep assertion messages as readable as the previous hard-coded versions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `assert_driver_check_called`, consider validating `check_type` against the supported options before calling `public_send` so that a typo or unexpected symbol yields a clearer failure than a `NoMethodError` on the driver.
- The error message in `assert_driver_check_called` now interpolates the raw `check_type` symbol; you might want to normalize or prettify it (e.g., `dimension check` instead of `dimension_check`) to keep assertion messages as readable as the previous hard-coded versions.

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.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pftg
Copy link
Copy Markdown
Collaborator Author

pftg commented Apr 13, 2026

CodeRabbit blank line finding already fixed in b6a50cc.

pftg and others added 2 commits April 13, 2026 11:21
Add pr-comment input to upload-screenshots composite action. When
enabled, it finds/creates a PR comment with report links automatically.
Also adds job summary with artifact links.

Removes ~40 lines of duplicated YAML from test.yml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Document pr-comment input for upload-screenshots action
- Document setup-ruby-and-dependencies action with inputs table
- Add full example combining both actions
- Move manual setup and update-baselines to collapsible sections
- Update README CI snippet to show pr-comment: 'true'

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pftg pftg merged commit 4070438 into master Apr 13, 2026
8 checks passed
@pftg pftg deleted the refactor/adr006-test-simplification-t3-t4-t6 branch April 13, 2026 09:32
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