Skip to content

Commit 5c3b401

Browse files
committed
Improve Kernel.autoload specs
1 parent 18eaa06 commit 5c3b401

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spec/ruby/core/kernel/autoload_spec.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def go
111111
end
112112
end
113113

114-
Kernel.autoload :KSAutoloadBB, "no_autoload.rb"
114+
Kernel.autoload :KSAutoloadBB, "autoload_never_used.rb"
115115

116116
describe "Kernel.autoload" do
117117
before :all do
@@ -133,8 +133,17 @@ def go
133133
Kernel.autoload?(:KSAutoloadAA).should == @non_existent
134134
end
135135

136-
it "sets the autoload constant in Object's constant table" do
136+
it "sets the autoload constant in the caller class's constant table" do
137137
Object.should have_constant(:KSAutoloadBB)
138+
Kernel.should_not have_constant(:KSAutoloadBB)
139+
140+
module KernelSpecs
141+
class AutoloadInCallerClass
142+
Kernel.autoload :KSAutoloadCC, "autoload_never_used.rb"
143+
AutoloadInCallerClass.should have_constant(:KSAutoloadCC)
144+
Kernel.should_not have_constant(:KSAutoloadBB)
145+
end
146+
end
138147
end
139148

140149
it "calls #to_path on non-String filenames" do
@@ -167,6 +176,9 @@ def go
167176
it "returns the name of the file that will be autoloaded" do
168177
Kernel.autoload :KSAutoload, "autoload.rb"
169178
Kernel.autoload?(:KSAutoload).should == "autoload.rb"
179+
Kernel.should_not have_constant(:KSAutoload)
180+
Object.should_not have_constant(:KSAutoload)
181+
self.class.should have_constant(:KSAutoload)
170182
end
171183

172184
it "returns nil if no file has been registered for a constant" do

0 commit comments

Comments
 (0)