Repository navigation
Fix NameError in place of a failed comparison when color is on - #7
Merged
Merged
Conversation
A failed comparison of long values raised NameError (ANSI::Diff) when color was on but had not been turned on with Assay.color = true, as under Rubytest. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In 0.5.0, a failed comparison of long values (more than 13 characters when inspected) could raise
NameError: uninitialized constant ANSI::Diffin place of the assertion.Cause
EqualAssay,UnequalAssayand the AE notation color the differences between the two values when$ansiis set. The diff library was only loaded byAssay.color = true. But the ANSI gem sets$ansiitself when it loads, so under Rubytest color is on without Assay having loadedansi/diff.Found while porting vclog's tests: a test that should have failed was reported as an error.
Fix
Assay.color_diff(a, b)requiresansi/diffand returns the two colored values. The three places that built anANSI::Diffcall it.test/color.rbchecks each of the three in a process of its own, with$ansiset from outside, and expects the right assertion class with a colored message. Without the fix all three fail with theNameError. It runs asrake color, part of the default task.🤖 Generated with Claude Code