diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/lib/puppettest.rb | 2 | ||||
-rwxr-xr-x | test/util/autoload.rb | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 64cb7aebe..902831e68 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -17,6 +17,8 @@ Dir["#{mainlib}/../vendor/gems/**"].each do |path| end end +require 'mocha' + # Only load the test/unit class if we're not in the spec directory. # Else we get the bogus 'no tests, no failures' message. unless Dir.getwd =~ /spec/ diff --git a/test/util/autoload.rb b/test/util/autoload.rb index 6babed774..3fe18352c 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -123,4 +123,23 @@ TestAutoload.newthing(:#{name.to_s}) Kernel.expects(:require).with(File.join(loadname, subname)) loader.loadall end + + def test_searchpath_includes_plugin_dirs + moddir = "/what/ever" + libdir = "/other/dir" + Puppet.settings.stubs(:value).with(:modulepath).returns(moddir) + Puppet.settings.stubs(:value).with(:libdir).returns(libdir) + + loadname = "testing" + loader = Puppet::Util::Autoload.new(self.class, loadname) + + # Currently, include both plugins and libs. + paths = %w{plugins lib}.inject({}) { |hash, d| hash[d] = File.join(moddir, "testing", d); FileTest.stubs(:directory?).with(hash[d]).returns(true); hash } + Dir.expects(:glob).with("#{moddir}/*/{plugins,lib}").returns(paths.values) + + searchpath = loader.searchpath + paths.each do |dir, path| + assert(searchpath.include?(path), "search path did not include path for %s" % dir) + end + end end |