Skip to content

Add test coverage for HashWithIndifferentAccess key access and except - #57689

Merged
byroot merged 1 commit into
rails:mainfrom
hammadxcm:test-hwia-key-access-and-except
Jun 13, 2026
Merged

byroot merged 1 commit into
rails:mainfrom
hammadxcm:test-hwia-key-access-and-except

Conversation

@hammadxcm

Copy link
Copy Markdown
Contributor

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.

  • fetch with a default value and with a block — the *extras passthrough; the block receives the converted (String) key. Existing fetch tests only pass a present key with no extras.
  • values_at with a missing key returns nil in that position (distinct from fetch_values, which raises). Existing tests only pass present keys.
  • dig returns nil for a missing key — the documented miss path (counters.dig(:zoo) # => nil); existing dig test only covers the success path.
  • except / without — previously had no test at all: returns a new HashWithIndifferentAccess, accepts mixed String/Symbol keys, and leaves the receiver unchanged.

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
@byroot
byroot merged commit 92f125d into rails:main Jun 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants