^ r make tests pass on all current Ruby versions
Description
Ruby 3.4 changed the behavior of Hash#inspect (bug 20433).
Because the Approvals::Writers::ArrayWriter and Approvals::Writers::HashWriter use #inspect to serialize the contents of arrays and hashes, this made it impossible to use a single fixture to verify their behavior on all current versions of Ruby.
The solution
I duplicated the tests for the behavior and added a [slightly ugly] conditional to the test suite to skip whichever version should NOT apply under the version of Ruby being used to execute the tests.
NOTE: because I will absolutely forget about this, I also added a "time bomb" to those tests that will begin failing after Ruby 3.3's official end-of-life date, and some comments about how to restore the code to its simpler state.
Summary by Sourcery
Update test suite to handle changes in Ruby 3.4's Hash#inspect behavior by adding version-specific test contexts
Bug Fixes:
- Modify test suite to support different Hash#inspect behaviors across Ruby versions
Tests:
- Add conditional test contexts to handle Ruby version-specific test variations
- Implement a 'time bomb' to remind future maintainers to clean up version-specific test code
Chores:
- Add version checking logic to test suite to manage compatibility across Ruby versions
Reviewer's Guide by Sourcery
This pull request addresses a change in Hash#inspect behavior introduced in Ruby 3.4 that affected the Approvals::Writers::ArrayWriter and Approvals::Writers::HashWriter. To ensure tests pass on all current Ruby versions, the test suite was modified to conditionally skip tests based on the Ruby version. A time bomb was added to remind developers to remove the conditional logic after Ruby 3.3's end-of-life.
No diagrams generated as the changes look simple and do not need a visual representation.
File-Level Changes
| Change | Details | Files |
|---|---|---|
Added conditional logic to the test suite to skip tests based on the Ruby version, accommodating changes in Hash#inspect behavior in Ruby 3.4. |
|
spec/approvals_spec.rb |
Added new approval fixtures to accommodate changes in Hash#inspect behavior in Ruby 3.4. |
|
spec/fixtures/approvals/approvals_supports_excluded_keys_option_while_were_still_supporting_ruby__34_in_ruby_versions_34_and_beyond_supports_the_array_writer.approved.txtspec/fixtures/approvals/approvals_supports_excluded_keys_option_while_were_still_supporting_ruby__34_in_ruby_versions_34_and_beyond_supports_the_hash_writer.approved.txt |
Tips and commands
Interacting with Sourcery
-
Trigger a new review: Comment
@sourcery-ai reviewon 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 issueto create an issue from it. -
Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. -
Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. -
Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. -
Resolve all Sourcery comments: Comment
@sourcery-ai resolveon 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 dismisson 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 reviewto trigger a new review! -
Generate a plan of action for an issue: Comment
@sourcery-ai planon an issue to generate a plan of action for it.
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
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Wow, that AI bot is annoying.
we fixed this a better way :)