Captures proc output instead of calling it#17
Merged
Conversation
There was a problem hiding this comment.
Caution
Changes requested ❌
Reviewed everything up to 30b3388 in 1 minute and 41 seconds. Click for details.
- Reviewed
117lines of code in3files - Skipped
0files when reviewing. - Skipped posting
1draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. lib/rspec/enriched_json/expectation_helper_wrapper.rb:50
- Draft comment:
Using global $stdout reassignment may lead to issues in concurrent environments. Consider a thread-safe approach if needed. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 30% vs. threshold = 50% This is a legitimate concern - modifying global state like $stdout can cause issues if multiple threads try to capture output simultaneously. However, this is in a test helper for RSpec, which typically runs tests sequentially. The code does properly restore the original stdout. The risk is real but may be acceptable for the testing context. I may be underestimating the likelihood of concurrent test execution. Some teams do run RSpec in parallel. While parallel test execution exists, RSpec's parallelization happens at the process level, not thread level, so each test process would have its own $stdout. The comment raises a valid concern but is likely overly cautious for this specific RSpec testing context where process-level parallelization is more common than thread-level.
Workflow ID: wflow_SDVDmL5nNwazctp6
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed 28c7483 in 34 seconds. Click for details.
- Reviewed
34lines of code in2files - Skipped
0files when reviewing. - Skipped posting
2draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. demo.rb:414
- Draft comment:
New 'Output Matchers' category added. Verify that the category name and ordering match your intended grouping for failing tests. The trailing comma is acceptable in Ruby. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. spec/oj_serialization_spec.rb:42
- Draft comment:
Removed Proc serialization tests. Ensure that capturing proc output (instead of calling it) is documented and that tests reflect the new intended behavior. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_qq4h7gCaSCJPsOg1
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
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.
A specific bug occurs with TodoList specs where the proc that is captured by the exception refers to a portion of the code which returns an array but outputs a string.
This array causes issues when showing the HTML diff:
To solve this, I capture the output of the proc instead of calling it.
Testing
Test this using the following script (add it to the root of this repository):
Both cases should return an actual that is a string — not an array.
Learn Output
The specs on Learn now look like this:
When the spec fails:

When the spec passes:

Important
Capture
Procoutput tostdoutinserialize_valueand add tests for output matchers.serialize_valueinExpectationHelperWrapperto captureProcoutput tostdoutinstead of calling it directly.demo.rb.Procserialization test inoj_serialization_spec.rb.stdout_matcher_spec.rbto test capturing ofstdoutoutput for passing and failing cases.0.8.3inversion.rb.This description was created by
for 28c7483. You can customize this summary. It will automatically update as commits are pushed.