@@ -111,7 +111,7 @@ def go
111
111
end
112
112
end
113
113
114
- Kernel . autoload :KSAutoloadBB , "no_autoload .rb"
114
+ Kernel . autoload :KSAutoloadBB , "autoload_never_used .rb"
115
115
116
116
describe "Kernel.autoload" do
117
117
before :all do
@@ -133,8 +133,17 @@ def go
133
133
Kernel . autoload? ( :KSAutoloadAA ) . should == @non_existent
134
134
end
135
135
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
137
137
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
138
147
end
139
148
140
149
it "calls #to_path on non-String filenames" do
@@ -167,6 +176,9 @@ def go
167
176
it "returns the name of the file that will be autoloaded" do
168
177
Kernel . autoload :KSAutoload , "autoload.rb"
169
178
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 )
170
182
end
171
183
172
184
it "returns nil if no file has been registered for a constant" do
0 commit comments