Skip to content

Fix is_default? for options with block defaults - #138

Open
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:fix-is-default-block-defaults
Open

tas50 wants to merge 1 commit into
chef:mainfrom
tas50:fix-is-default-block-defaults

Conversation

@tas50

@tas50 tas50 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

is_default? compared the stored value against default_value, which is always nil when an option's default is a block. With default(:attr) { x * 2 }:

  • setting attr to the value the block computes returned false
  • setting attr to nil returned true

It now compares against Configurable#default, which evaluates the block (or returns the static default).

Tests

Added specs under "When config has a default value block" covering unset, set to the computed value, set to nil, and set to another value. The two broken cases failed before the change. The full suite passes (160 examples) and cookstyle is clean.

@tas50
tas50 requested review from a team and jaymzh as code owners September 25, 2026 20:54
@jaymzh
jaymzh force-pushed the fix-is-default-block-defaults branch from aa40769 to b3b6d8f Compare September 27, 2026 22:20
is_default? compared the current value against default_value, which is
always nil when the default is a block. Setting an option to the value
its block computes reported false, and setting it to nil reported true.
Compare against the computed default instead.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 force-pushed the fix-is-default-block-defaults branch from b3b6d8f to c384eaa Compare September 28, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants