Repository navigation
Add test coverage for HashWithIndifferentAccess key access and except - #57689
Merged
Merged
Conversation
Cover untested branches and a documented-but-untested method of ActiveSupport::HashWithIndifferentAccess: - fetch with a default value and with a block (the *extras passthrough) - values_at with a missing key returns nil in that position - dig returns nil for a missing key - except / without (entirely untested) returns a new HashWithIndifferentAccess, leaving the receiver unchanged
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 coverage for several untested branches and a documented-but-entirely-untested method of
ActiveSupport::HashWithIndifferentAccess. Each is a distinct branch with no conceptually-equivalent existing test. Test-only; no production changes.fetchwith a default value and with a block — the*extraspassthrough; the block receives the converted (String) key. Existingfetchtests only pass a present key with no extras.values_atwith a missing key returnsnilin that position (distinct fromfetch_values, which raises). Existing tests only pass present keys.digreturnsnilfor a missing key — the documented miss path (counters.dig(:zoo) # => nil); existingdigtest only covers the success path.except/without— previously had no test at all: returns a newHashWithIndifferentAccess, accepts mixed String/Symbol keys, and leaves the receiver unchanged.