summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/module.rb2
-rwxr-xr-xspec/unit/module.rb8
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb
index 701e4b258..a9f845d6a 100644
--- a/lib/puppet/module.rb
+++ b/lib/puppet/module.rb
@@ -110,7 +110,7 @@ class Puppet::Module
# Find this module in the modulepath.
def path
- self.class.modulepath.collect { |path| File.join(path, name) }.find { |d| FileTest.exist?(d) }
+ environment.modulepath.collect { |path| File.join(path, name) }.find { |d| FileTest.exist?(d) }
end
# Find all plugin directories. This is used by the Plugins fileserving mount.
diff --git a/spec/unit/module.rb b/spec/unit/module.rb
index 4ff69695e..60c198ea9 100755
--- a/spec/unit/module.rb
+++ b/spec/unit/module.rb
@@ -45,10 +45,12 @@ describe Puppet::Module do
Puppet::Module.new("foo", env).environment.should equal(env)
end
- it "should return the path to the first found instance in its module paths as its path" do
+ it "should return the path to the first found instance in its environment's module paths as its path" do
mod = Puppet::Module.new("foo")
- paths = %w{/a /b /c}
- Puppet::Module.stubs(:modulepath).returns paths
+ env = mock 'environment'
+ mod.stubs(:environment).returns env
+
+ env.expects(:modulepath).returns %w{/a /b /c}
FileTest.expects(:exist?).with("/a/foo").returns false
FileTest.expects(:exist?).with("/b/foo").returns true