File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,29 @@ module ModuleSpecs::Autoload
274
274
end
275
275
end
276
276
277
+ describe "after the autoload is triggered by require" do
278
+ before :each do
279
+ @path = tmp ( "autoload.rb" )
280
+ end
281
+
282
+ after :each do
283
+ rm_r @path
284
+ end
285
+
286
+ it "the mapping feature to autoload is removed, and a new autoload with the same path is considered" do
287
+ ModuleSpecs ::Autoload . autoload :RequireMapping1 , @path
288
+ touch ( @path ) { |f | f . puts "ModuleSpecs::Autoload::RequireMapping1 = 1" }
289
+ ModuleSpecs ::Autoload ::RequireMapping1 . should == 1
290
+
291
+ $LOADED_FEATURES. delete ( @path )
292
+ ModuleSpecs ::Autoload . autoload :RequireMapping2 , @path [ 0 ...-3 ]
293
+ touch ( @path ) { |f | f . puts "ModuleSpecs::Autoload::RequireMapping2 = 2" }
294
+ ModuleSpecs ::Autoload ::RequireMapping2 . should == 2
295
+
296
+ ModuleSpecs ::Autoload . send :remove_const , :RequireMapping2
297
+ end
298
+ end
299
+
277
300
describe "during the autoload before the constant is assigned" do
278
301
before :each do
279
302
@path = fixture ( __FILE__ , "autoload_during_autoload.rb" )
You can’t perform that action at this time.
0 commit comments