diff options
| author | Paul Nasrat <pnasrat@googlemail.com> | 2008-09-16 10:24:19 +0100 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-09-20 19:43:56 +1000 |
| commit | 7f8abbd388ee3898c8505ca3bb884b75d8db2087 (patch) | |
| tree | e0c8f950d1f9bf9364a85a27a12a1a5c4cefd8c5 /spec/unit/module.rb | |
| parent | 09057346dd7207e36c81bae479d1343fb7cc8d0a (diff) | |
| download | puppet-7f8abbd388ee3898c8505ca3bb884b75d8db2087.tar.gz puppet-7f8abbd388ee3898c8505ca3bb884b75d8db2087.tar.xz puppet-7f8abbd388ee3898c8505ca3bb884b75d8db2087.zip | |
Bug #1550 - Rework to avoid regressing rspec tests, add new rspec tests for templatedir as a path
Signed-off-by: Paul Nasrat <pnasrat@googlemail.com>
Diffstat (limited to 'spec/unit/module.rb')
| -rwxr-xr-x | spec/unit/module.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/spec/unit/module.rb b/spec/unit/module.rb index e79001ae1..4d66550b5 100755 --- a/spec/unit/module.rb +++ b/spec/unit/module.rb @@ -90,23 +90,44 @@ describe Puppet::Module, " when searching for templates" do end it "should use the main templatedir if no module is found" do - Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates") + Puppet::Module.stubs(:templatepath).with(nil).returns(["/my/templates"]) Puppet::Module.expects(:find).with("mymod", nil).returns(nil) Puppet::Module.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate" end it "should return unqualified templates directly in the template dir" do - Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates") + Puppet::Module.stubs(:templatepath).with(nil).returns(["/my/templates"]) Puppet::Module.expects(:find).never Puppet::Module.find_template("mytemplate").should == "/my/templates/mytemplate" end it "should use the environment templatedir if no module is found and an environment is specified" do - Puppet.settings.expects(:value).with(:templatedir, "myenv").returns("/myenv/templates") + Puppet::Module.stubs(:templatepath).with("myenv").returns(["/myenv/templates"]) + Puppet::Module.expects(:find).with("mymod", "myenv").returns(nil) + Puppet::Module.find_template("mymod/mytemplate", "myenv").should == "/myenv/templates/mymod/mytemplate" + end + + it "should use first dir from environment templatedir if no module is found and an environment is specified" do + Puppet::Module.stubs(:templatepath).with("myenv").returns(["/myenv/templates", "/two/templates"]) Puppet::Module.expects(:find).with("mymod", "myenv").returns(nil) Puppet::Module.find_template("mymod/mytemplate", "myenv").should == "/myenv/templates/mymod/mytemplate" end + it "should use a valid dir when templatedir is a path for unqualified templates and the first dir contains template" do + Puppet::Module.stubs(:templatepath).returns(["/one/templates", "/two/templates"]) + File.expects(:exists?).with("/one/templates/mytemplate").returns(true) + Puppet::Module.expects(:find).never + Puppet::Module.find_template("mytemplate").should == "/one/templates/mytemplate" + end + + it "should use a valid dir when templatedir is a path for unqualified templates and only second dir contains template" do + Puppet::Module.stubs(:templatepath).returns(["/one/templates", "/two/templates"]) + File.expects(:exists?).with("/one/templates/mytemplate").returns(false) + File.expects(:exists?).with("/two/templates/mytemplate").returns(true) + Puppet::Module.expects(:find).never + Puppet::Module.find_template("mytemplate").should == "/two/templates/mytemplate" + end + it "should use the node environment if specified" do Puppet.settings.stubs(:value).returns.returns("/my/directory") Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/my/modules") |
