diff options
author | Luke Kanies <luke@madstop.com> | 2009-08-31 16:01:17 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-09-01 21:04:06 +1000 |
commit | d397f8d1d1092067f7ca52449ce9af63f02f44e1 (patch) | |
tree | f7ec36c5e05bd55b8e21fce565f493a85e2f65a0 /spec/unit/util/autoload.rb | |
parent | 800a78b993f15e2d77312bf207929ec876e9b227 (diff) | |
download | puppet-d397f8d1d1092067f7ca52449ce9af63f02f44e1.tar.gz puppet-d397f8d1d1092067f7ca52449ce9af63f02f44e1.tar.xz puppet-d397f8d1d1092067f7ca52449ce9af63f02f44e1.zip |
Fixing #2574 - autoloading finds plugins in modules
We had some stupid errors that were preventing this
from happening; this fixes them and adds an
integration test.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/util/autoload.rb')
-rwxr-xr-x | spec/unit/util/autoload.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/spec/unit/util/autoload.rb b/spec/unit/util/autoload.rb index c4a8642a0..18938125d 100755 --- a/spec/unit/util/autoload.rb +++ b/spec/unit/util/autoload.rb @@ -22,9 +22,9 @@ describe Puppet::Util::Autoload do describe "when building the search path" do it "should collect all of the plugins and lib directories that exist in the current environment's module path" do Puppet.settings.expects(:value).with(:environment).returns "foo" - Puppet.settings.expects(:value).with(:modulepath, "foo").returns %w{/a /b /c} - Dir.expects(:entries).with("/a").returns %w{/a/one /a/two} - Dir.expects(:entries).with("/b").returns %w{/b/one /b/two} + Puppet.settings.expects(:value).with(:modulepath, :foo).returns "/a:/b:/c" + Dir.expects(:entries).with("/a").returns %w{one two} + Dir.expects(:entries).with("/b").returns %w{one two} FileTest.stubs(:directory?).returns false FileTest.expects(:directory?).with("/a").returns true @@ -36,6 +36,20 @@ describe Puppet::Util::Autoload do @autoload.module_directories.should == %w{/a/one/plugins /a/two/lib /b/one/plugins /b/two/lib} end + it "should not look for lib directories in directories starting with '.'" do + Puppet.settings.expects(:value).with(:environment).returns "foo" + Puppet.settings.expects(:value).with(:modulepath, :foo).returns "/a" + Dir.expects(:entries).with("/a").returns %w{. ..} + + FileTest.expects(:directory?).with("/a").returns true + FileTest.expects(:directory?).with("/a/./lib").never + FileTest.expects(:directory?).with("/a/./plugins").never + FileTest.expects(:directory?).with("/a/../lib").never + FileTest.expects(:directory?).with("/a/../plugins").never + + @autoload.module_directories + end + it "should include the module directories, the Puppet libdir, and all of the Ruby load directories" do @autoload.expects(:module_directories).returns %w{/one /two} @autoload.search_directories.should == ["/one", "/two", Puppet[:libdir], $:].flatten |