Skip to content

Ruby: Implement Herb/IncludesAssertion RuboCop cop - #2397

Merged
marcoroth merged 1 commit into
mainfrom
rubocop-includes-assertion-cop
Sep 10, 2026
Merged

marcoroth merged 1 commit into
mainfrom
rubocop-includes-assertion-cop

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 24, 2026

Copy link
Copy Markdown
Owner

This pull request implements a custom RuboCop cop that flags assert_includes and refute_includes in the test suite, so new tests reach for the assert_*_snapshot helpers instead of asserting against a substring of the output.

Herb's tests snapshot the whole compiled or rendered output, which keeps a failure showing the entire diff instead of a single matched fragment. This cop keeps that convention enforced as new tests are added.

# bad
assert_includes result.errors.first.message, "unexpected token"

# good
assert_parsed_snapshot(source)

The cop reports:

Do not use `assert_includes`. Use one of the `assert_*_snapshot` helpers instead.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 5e3d905


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Aug 24, 2026

Copy link
Copy Markdown
@herb-tools/analysis

npx https://pkg.pr.new/@herb-tools/analysis@2397

@herb-tools/browser

npx https://pkg.pr.new/@herb-tools/browser@2397

@herb-tools/client

npx https://pkg.pr.new/@herb-tools/client@2397

@herb-tools/config

npx https://pkg.pr.new/@herb-tools/config@2397

@herb-tools/core

npx https://pkg.pr.new/@herb-tools/core@2397

@herb-tools/dev-tools

npx https://pkg.pr.new/@herb-tools/dev-tools@2397

@herb-tools/formatter

npx https://pkg.pr.new/@herb-tools/formatter@2397

herb-language-server

npx https://pkg.pr.new/herb-language-server@2397

@herb-tools/highlighter

npx https://pkg.pr.new/@herb-tools/highlighter@2397

@herb-tools/language-server

npx https://pkg.pr.new/@herb-tools/language-server@2397

@herb-tools/language-service

npx https://pkg.pr.new/@herb-tools/language-service@2397

@herb-tools/linter

npx https://pkg.pr.new/@herb-tools/linter@2397

@herb-tools/node

npx https://pkg.pr.new/@herb-tools/node@2397

@herb-tools/node-wasm

npx https://pkg.pr.new/@herb-tools/node-wasm@2397

@herb-tools/printer

npx https://pkg.pr.new/@herb-tools/printer@2397

@herb-tools/rewriter

npx https://pkg.pr.new/@herb-tools/rewriter@2397

stimulus-lint

npx https://pkg.pr.new/stimulus-lint@2397

@herb-tools/tailwind-class-sorter

npx https://pkg.pr.new/@herb-tools/tailwind-class-sorter@2397

commit: 5e3d905

@marcoroth
marcoroth force-pushed the rubocop-includes-assertion-cop branch from d77796d to 5e3d905 Compare September 10, 2026 14:26
@marcoroth
marcoroth merged commit 81f9bb3 into main Sep 10, 2026
24 of 26 checks passed
@marcoroth
marcoroth deleted the rubocop-includes-assertion-cop branch September 10, 2026 15:21
marcoroth added a commit that referenced this pull request Sep 11, 2026
Follow up on #2397, which added the `Herb/IncludesAssertion` cop and
parked the existing `assert_includes` and `refute_includes` calls in
`.rubocop_todo.yml`.

This pull request adds the assertion each of those calls will be
replaced with, right next to the original, so both run and pass
together. It is the first of two pull requests that burn the todo list
down. This one only adds, so nothing is removed and the cop stays green.
The second one deletes the `assert_includes` and `refute_includes` lines
and drops the files from `.rubocop_todo.yml`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine Herb engine and Rails template compilation ruby Ruby source for the gem and its libraries rubygem The herb RubyGem and its packaging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant