Skip to content

Engine: Add helpers to compare compiled/rendered outputs of the Engine#774

Merged
marcoroth merged 2 commits intomainfrom
compare-tools
Nov 3, 2025
Merged

Engine: Add helpers to compare compiled/rendered outputs of the Engine#774
marcoroth merged 2 commits intomainfrom
compare-tools

Conversation

@marcoroth
Copy link
Owner

This commit adds comprehensive tooling to compare Herb::Engine's output against Erubi::Engine for both the compiled templates and the rendered templates.

It introduces three CLI tools: bin/compare for full comparisons, bin/compare-compile for compiled source comparisons, and bin/compare-render for rendered output comparisons.

All tools use difftastic to provide rich diffs showing both string-level and semantic differences (Ruby AST for compiled code, HTML structure for rendered output).

CleanShot 2025-11-03 at 21 17 47@2x CleanShot 2025-11-03 at 21 17 40@2x

It also adds these helpers in snapshot_utils.rb so we can also run the comparison for all assert_evaluated_snapshot and assert_compiled_snapshot in the test suite using COMPARE_WITH_ERUBI=true

COMPARE_WITH_ERUBI=true mtest
COMPARE_WITH_ERUBI=true mtest test/engine/evaluation_test.rb

Erubi compatibility is critical for Herb's adoption. Erubi is the de facto standard ERB implementation used across the Ruby ecosystem, particularly in Rails.

These comparison helpers serve as both documentation and verification of our compatibility commitment. They help catch regressions during development and make it trivial to investigate any differences between implementations.

@marcoroth marcoroth merged commit 0bbd01b into main Nov 3, 2025
24 checks passed
@marcoroth marcoroth deleted the compare-tools branch November 3, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant