Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions core/module/autoload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,21 @@ def r
end
end

it "should trigger the autoload when using `private_constant`" do
@remove << :DynClass
module ModuleSpecs::Autoload
autoload :DynClass, fixture(__FILE__, "autoload_c.rb")
private_constant :DynClass

ScratchPad.recorded.should be_nil

DynClass::C.new.loaded.should == :dynclass_c
ScratchPad.recorded.should == :loaded
end

-> { ModuleSpecs::Autoload::DynClass }.should raise_error(NameError, /private constant/)
end

# [ruby-core:19127] [ruby-core:29941]
it "does NOT raise a NameError when the autoload file did not define the constant and a module is opened with the same name" do
module ModuleSpecs::Autoload
Expand Down
Loading