diff options
| author | Luke Kanies <luke@madstop.com> | 2009-02-17 17:55:57 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2009-02-18 22:38:45 -0600 |
| commit | 2573ef1c4c2d472f9cf41ab3a1b67b7408d704b4 (patch) | |
| tree | 56a20fea8bed3cf997bcf16fca5fbb98f0f66c9a /spec/unit/node | |
| parent | 9c18d5aa4214f565b81b6cac07736fe072954bb1 (diff) | |
| download | puppet-2573ef1c4c2d472f9cf41ab3a1b67b7408d704b4.tar.gz puppet-2573ef1c4c2d472f9cf41ab3a1b67b7408d704b4.tar.xz puppet-2573ef1c4c2d472f9cf41ab3a1b67b7408d704b4.zip | |
Added support for finding modules from an environment
This uses the environment to search for the modules, rather
than relying on the Puppet::Module class to know how to
handle environments.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/node')
| -rwxr-xr-x | spec/unit/node/environment.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/node/environment.rb b/spec/unit/node/environment.rb index 48fe64280..0878a2a0c 100755 --- a/spec/unit/node/environment.rb +++ b/spec/unit/node/environment.rb @@ -33,5 +33,43 @@ describe Puppet::Node::Environment do env = Puppet::Node::Environment.new("testing") env["myvar"].should == "myval" end + + it "should be able to return its modules" do + Puppet::Node::Environment.new("testing").should respond_to(:modules) + end + + it "should return each module from the environment-specific module path when asked for its modules" do + env = Puppet::Node::Environment.new("testing") + module_path = %w{/one /two}.join(File::PATH_SEPARATOR) + env.expects(:[]).with(:modulepath).returns module_path + + Puppet::Module.expects(:each_module).with(module_path).multiple_yields("mod1", "mod2") + + env.modules.should == %w{mod1 mod2} + end + + it "should be able to return an individual module by matching the module name" do + env = Puppet::Node::Environment.new("testing") + module_path = %w{/one /two}.join(File::PATH_SEPARATOR) + env.expects(:[]).with(:modulepath).returns module_path + + one = stub 'one', :name => 'one' + two = stub 'two', :name => 'two' + Puppet::Module.expects(:each_module).with(module_path).multiple_yields(one, two) + + env.module("two").should equal(two) + end + + it "should return nil if asked for a module that is not in its path" do + env = Puppet::Node::Environment.new("testing") + module_path = %w{/one /two}.join(File::PATH_SEPARATOR) + env.expects(:[]).with(:modulepath).returns module_path + + one = stub 'one', :name => 'one' + two = stub 'two', :name => 'two' + Puppet::Module.expects(:each_module).with(module_path).multiple_yields(one, two) + + env.module("three").should be_nil + end end end |
