Repository navigation
Add assert_hash_attributes extracted from Catberry - #1
Merged
Merged
Conversation
Applies the same nil, Time, and rich text comparisons as assert_attributes to hash values. Keys are looked up as given, then as strings, so symbol keys match parsed JSON. A missing key fails, even when the expected value is nil.
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.
Adds
assert_hash_attributes(hash, **expected), the hash counterpart toassert_attributes, extracted from Catberry's test helpers.Changes
nil,Time, rich text, andassert_equalbranches move into a privateassert_value, used by both assertions.assert_attributesfailure messages are unchanged.Expected hash to have key :nickname, but its keys were [...], even when the expected value isnil. Catberry's version treated a missing key asnil.Metrics/ClassLengthis excluded for tests, alongside the existingMetrics/AbcSizeexclusion.Testing
bundle exec rake: 27 runs, 0 failures; RuboCop clean. Every branch has a passing case and a failing case that checks the message, plus symbol vs. string keys and missing keys.