[Pkg-puppet-devel] [facter] 84/352: (fact-163) Fix path construction in load_all

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:34 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 4faecb0e97cba7396da91598658aaecd137f7be1
Author: Kylo Ginsberg <kylo at puppetlabs.com>
Date:   Thu Dec 19 22:02:41 2013 -0800

    (fact-163) Fix path construction in load_all
---
 lib/facter/util/loader.rb     |  3 +--
 spec/unit/util/loader_spec.rb | 10 +++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/facter/util/loader.rb b/lib/facter/util/loader.rb
index 1d4bfef..4b94676 100644
--- a/lib/facter/util/loader.rb
+++ b/lib/facter/util/loader.rb
@@ -43,8 +43,7 @@ class Facter::Util::Loader
     unless paths.nil?
       paths.each do |dir|
         # dir is already an absolute path
-        Dir.glob(File.join(dir, '*.rb')).each do |dirent|
-          path = File.join(dir, dirent)
+        Dir.glob(File.join(dir, '*.rb')).each do |path|
           # exclude dirs that end with .rb
           load_file(path) if File.file?(path)
         end
diff --git a/spec/unit/util/loader_spec.rb b/spec/unit/util/loader_spec.rb
index 632db37..e537dd1 100755
--- a/spec/unit/util/loader_spec.rb
+++ b/spec/unit/util/loader_spec.rb
@@ -207,8 +207,8 @@ describe Facter::Util::Loader do
     it "should load all files in all search paths" do
       @loader.expects(:search_path).returns %w{/one/dir /two/dir}
 
-      Dir.expects(:glob).with('/one/dir/*.rb').returns %w{a.rb b.rb}
-      Dir.expects(:glob).with('/two/dir/*.rb').returns %w{c.rb d.rb}
+      Dir.expects(:glob).with('/one/dir/*.rb').returns %w{/one/dir/a.rb /one/dir/b.rb}
+      Dir.expects(:glob).with('/two/dir/*.rb').returns %w{/two/dir/c.rb /two/dir/d.rb}
 
       %w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each do |f|
         File.expects(:file?).with(f).returns true
@@ -222,13 +222,13 @@ describe Facter::Util::Loader do
       @loader.expects(:search_path).returns %w{/one/dir /two/dir}
 
       # a.rb is a directory
-      Dir.expects(:glob).with('/one/dir/*.rb').returns %w{a.rb b.rb}
+      Dir.expects(:glob).with('/one/dir/*.rb').returns %w{/one/dir/a.rb /one/dir/b.rb}
       File.expects(:file?).with('/one/dir/a.rb').returns false
       File.expects(:file?).with('/one/dir/b.rb').returns true
       Kernel.expects(:load).with('/one/dir/b.rb')
 
       # c.rb is a directory
-      Dir.expects(:glob).with('/two/dir/*.rb').returns %w{c.rb d.rb}
+      Dir.expects(:glob).with('/two/dir/*.rb').returns %w{/two/dir/c.rb /two/dir/d.rb}
       File.expects(:file?).with('/two/dir/c.rb').returns false
       File.expects(:file?).with('/two/dir/d.rb').returns true
       Kernel.expects(:load).with('/two/dir/d.rb')
@@ -239,7 +239,7 @@ describe Facter::Util::Loader do
     it "should not raise an exception when a file is unloadable" do
       @loader.expects(:search_path).returns %w{/one/dir}
 
-      Dir.expects(:glob).with('/one/dir/*.rb').returns %w{a.rb}
+      Dir.expects(:glob).with('/one/dir/*.rb').returns %w{/one/dir/a.rb}
       File.expects(:file?).with('/one/dir/a.rb').returns true
 
       Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list