From eb40966777beaff2ceca8b91e10e3cb0132ec218 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 16 Jun 2009 13:25:07 -0500 Subject: Ruby no longer clobbers puppet autoloading We basically just make sure that we tell Ruby about files we've loaded, so you can 'require' these files and doing so will essentially no-op, rather than clobbering the already-loaded code. Signed-off-by: Luke Kanies --- spec/unit/util/autoload.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'spec/unit/util/autoload.rb') diff --git a/spec/unit/util/autoload.rb b/spec/unit/util/autoload.rb index d05bc15f0..c4a8642a0 100755 --- a/spec/unit/util/autoload.rb +++ b/spec/unit/util/autoload.rb @@ -82,12 +82,21 @@ describe Puppet::Util::Autoload do @autoload.should be_named_file_missing("foo") end + + it "should register loaded files with the main loaded file list so they are not reloaded by ruby" do + @autoload.stubs(:file_exist?).returns true + Kernel.stubs(:load) + + @autoload.load("myfile") + + $".should be_include("tmp/myfile.rb") + end end describe "when loading all files" do before do @autoload.stubs(:searchpath).returns %w{/a} - Dir.stubs(:glob).returns "file.rb" + Dir.stubs(:glob).returns "/path/to/file.rb" end [RuntimeError, LoadError, SyntaxError].each do |error| @@ -97,5 +106,11 @@ describe Puppet::Util::Autoload do lambda { @autoload.loadall }.should_not raise_error end end + + it "should require the full path to the file" do + Kernel.expects(:require).with("/path/to/file.rb") + + @autoload.loadall + end end end -- cgit