Skip to content

Commit 18eaa06

Browse files
committed
Adapt spec to not require undefined constants
1 parent 4a24507 commit 18eaa06

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

spec/ruby/core/module/autoload_spec.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,25 +299,28 @@ module ModuleSpecs::Autoload
299299
autoload :RequiredDirectlyNoConstant, fixture(__FILE__, "autoload_required_directly_no_constant.rb")
300300
end
301301
@path = fixture(__FILE__, "autoload_required_directly_no_constant.rb")
302-
@remove << :RequiredDirectlyNoConstant
303302
@check = -> {
304303
[
305304
defined?(ModuleSpecs::Autoload::RequiredDirectlyNoConstant),
306-
ModuleSpecs::Autoload.constants(false).include?(:RequiredDirectlyNoConstant),
307305
ModuleSpecs::Autoload.const_defined?(:RequiredDirectlyNoConstant),
308306
ModuleSpecs::Autoload.autoload?(:RequiredDirectlyNoConstant)
309307
]
310308
}
311309
ScratchPad.record @check
312-
@check.call.should == ["constant", true, true, @path]
310+
@check.call.should == ["constant", true, @path]
313311
$:.push File.dirname(@path)
314312
begin
315313
require "autoload_required_directly_no_constant.rb"
316314
ensure
317315
$:.pop
318316
end
319-
ScratchPad.recorded.should == [nil, true, false, nil]
320-
@check.call.should == [nil, true, false, nil]
317+
ScratchPad.recorded.should == [nil, false, nil]
318+
@check.call.should == [nil, false, nil]
319+
320+
# undefined constant, CRuby 3.1 & 3.2 still do it here, but it is inconsistent, the constant should be removed
321+
if ModuleSpecs::Autoload.constants(false).include?(:RequiredDirectlyNoConstant)
322+
@remove << :RequiredDirectlyNoConstant
323+
end
321324
end
322325
end
323326

0 commit comments

Comments
 (0)