diff options
Diffstat (limited to 'spec/ruby/core/module')
-rw-r--r-- | spec/ruby/core/module/autoload_spec.rb | 12 | ||||
-rw-r--r-- | spec/ruby/core/module/fixtures/classes.rb | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb index eaad4b8df6..09fbafd51c 100644 --- a/spec/ruby/core/module/autoload_spec.rb +++ b/spec/ruby/core/module/autoload_spec.rb @@ -11,6 +11,18 @@ describe "Module#autoload?" do it "returns nil if no file has been registered for a constant" do ModuleSpecs::Autoload.autoload?(:Manualload).should be_nil end + + it "returns the name of the file that will be autoloaded if an ancestor defined that autoload" do + ModuleSpecs::Autoload::Parent.autoload :AnotherAutoload, "another_autoload.rb" + ModuleSpecs::Autoload::Child.autoload?(:AnotherAutoload).should == "another_autoload.rb" + end + + ruby_version_is "2.7" do + it "returns nil if an ancestor defined that autoload but recursion is disabled" do + ModuleSpecs::Autoload::Parent.autoload :AnotherAutoload, "another_autoload.rb" + ModuleSpecs::Autoload::Child.autoload?(:AnotherAutoload, false).should be_nil + end + end end describe "Module#autoload" do diff --git a/spec/ruby/core/module/fixtures/classes.rb b/spec/ruby/core/module/fixtures/classes.rb index f93c39683e..ef70eaf9cf 100644 --- a/spec/ruby/core/module/fixtures/classes.rb +++ b/spec/ruby/core/module/fixtures/classes.rb @@ -386,6 +386,12 @@ module ModuleSpecs end end + class Parent + end + + class Child < Parent + end + module FromThread module A autoload :B, fixture(__FILE__, "autoload_empty.rb") |