From 595c04e0a92cea7a944498f013a0e65b88558175 Mon Sep 17 00:00:00 2001 From: "takahiro.miyamoto" Date: Fri, 12 Sep 2025 10:38:54 +0900 Subject: [PATCH] Proc returns `@val` only when val is nil --- lib/configatron/proc.rb | 2 +- test/unit/configatron/proc.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/configatron/proc.rb b/lib/configatron/proc.rb index 3ea7a07..97234dd 100644 --- a/lib/configatron/proc.rb +++ b/lib/configatron/proc.rb @@ -18,7 +18,7 @@ def call @val = val end end - return val || @val + return val.nil? ? @val : val end def finalize? diff --git a/test/unit/configatron/proc.rb b/test/unit/configatron/proc.rb index 303d455..24d55c9 100644 --- a/test/unit/configatron/proc.rb +++ b/test/unit/configatron/proc.rb @@ -20,5 +20,11 @@ class Critic::Unit::ProcTest < Critic::Unit::Test @proc.stubs(:finalize?).returns(false) refute_equal(@proc.call, @proc.call) end + + it 'sets and returns false in Dynamic' do + stubs(:rand).returns(false) + @proc.stubs(:finalize?).returns(false) + assert_equal(false, @proc.call) + end end end