Repository navigation
Conversation
…and reload `EnvConfiguration`, `DotEnvConfiguration`, and `EncryptedConfiguration` all have tests for `option`'s `default:` keyword, but `CombinedConfiguration` -- which composes them and applies its own default when no backend holds the key -- had none. `#keys` was only exercised indirectly through `#inspect`, and `#reload` was not covered at all. Add tests for the missing-key, static default, callable default, and present-key-does-not-trigger-default cases, plus direct coverage of `#keys` and `#reload`.
This branch has not been deployed
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.
Summary
ActiveSupport::CombinedConfigurationcomposes the configuration backends and applies its own fallback when none of them holds a key, but that fallback had no tests.All three backends cover
option'sdefault:keyword:env_configuration_test.rb— static default, callable default,false/nilfrom the block, present key not triggering the defaultdot_env_configuration_test.rb— same setencrypted_configuration_test.rb— same setcombined_configuration_test.rbhad none of them. It also never called#keysdirectly (only indirectly through the#inspectassertion), and never called#reload.What this adds
Six tests, named to match the existing backend tests:
optionwith a missing key returnsniloptionwith a missing key returns a staticdefault:optionwith a missing key calls a callabledefault:optionwith a present key returns the value without invoking thedefault:blockkeysreturns symbolized, de-duplicated keys drawn from every backend, not just the firstreloadpicks up a value added at runtimeNo behavior changes —
lib/is untouched, so no CHANGELOG entry.Verification
I checked the tests actually fail when the behavior regresses, by temporarily mutating
combined_configuration.rb:optionignoresdefault:keysreturns only the first backend's keysreloadbecomes a no-oprubocopis clean.