diff options
author | Luke Kanies <luke@madstop.com> | 2007-10-03 16:32:10 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-10-03 16:32:10 -0500 |
commit | b45a7ca82d9c59d577c2eedb18531f64e55813d1 (patch) | |
tree | aa3dee742340f57315d82101147de530eadbda34 /spec/unit | |
parent | fa643e61c7451c2c46623d2c801a42c6c7640e1e (diff) | |
download | puppet-b45a7ca82d9c59d577c2eedb18531f64e55813d1.tar.gz puppet-b45a7ca82d9c59d577c2eedb18531f64e55813d1.tar.xz puppet-b45a7ca82d9c59d577c2eedb18531f64e55813d1.zip |
Adding more behaviours to the Puppet::Module spec,
and fixing some bugs in the process.
Specifically, modules were no longer correctly handling
fully qualified files, and they do so once again.
Diffstat (limited to 'spec/unit')
-rwxr-xr-x | spec/unit/other/modules.rb | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/spec/unit/other/modules.rb b/spec/unit/other/modules.rb index f53c43e89..26ca3907d 100755 --- a/spec/unit/other/modules.rb +++ b/spec/unit/other/modules.rb @@ -108,22 +108,55 @@ describe Puppet::Module, " when searching for templates" do after { Puppet.settings.clear } end -describe Puppet::Module, " when searching for manifests" do - it "should return the manifests from the first found module" do - Puppet[:modulepath] = "/one:/two" - File.stubs(:directory?).returns(true) - Dir.expects(:glob).with("/one/mymod/manifests/init.pp").returns(%w{/one/mymod/manifests/init.pp}) - Puppet::Module.find_manifests("mymod/init.pp").should == ["/one/mymod/manifests/init.pp"] +describe Puppet::Module, " when searching for manifests when no module is found" do + before do + File.stubs(:find).returns(nil) end - it "should search the cwd if no module is found" do - Puppet[:modulepath] = "/one:/two" - File.stubs(:find).returns(nil) + it "should not look for modules when paths are fully qualified" do + Puppet.expects(:value).with(:modulepath).never + file = "/fully/qualified/file.pp" + Dir.stubs(:glob).with(file).returns([file]) + Puppet::Module.find_manifests(file) + end + + it "should directly return fully qualified files" do + file = "/fully/qualified/file.pp" + Dir.stubs(:glob).with(file).returns([file]) + Puppet::Module.find_manifests(file).should == [file] + end + + it "should match against provided fully qualified patterns" do + pattern = "/fully/qualified/pattern/*" + Dir.expects(:glob).with(pattern).returns(%w{my file list}) + Puppet::Module.find_manifests(pattern).should == %w{my file list} + end + + it "should look for files relative to the current directory" do cwd = Dir.getwd Dir.expects(:glob).with("#{cwd}/mymod/init.pp").returns(["#{cwd}/mymod/init.pp"]) Puppet::Module.find_manifests("mymod/init.pp").should == ["#{cwd}/mymod/init.pp"] end + it "should only return files, not directories" do + pattern = "/fully/qualified/pattern/*" + file = "/my/file" + dir = "/my/directory" + Dir.expects(:glob).with(pattern).returns([file, dir]) + FileTest.expects(:directory?).with(file).returns(false) + FileTest.expects(:directory?).with(dir).returns(true) + Puppet::Module.find_manifests(pattern).should == [file] + end +end + +describe Puppet::Module, " when searching for manifests in a found module" do + it "should return the manifests from the first found module" do + Puppet[:modulepath] = "/one:/two" + File.stubs(:directory?).returns(true) + Dir.expects(:glob).with("/one/mymod/manifests/init.pp").returns(%w{/one/mymod/manifests/init.pp}) + Puppet::Module.find_manifests("mymod/init.pp").should == ["/one/mymod/manifests/init.pp"] + end + it "should use the node environment if specified" do Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/env/modules") File.stubs(:directory?).returns(true) |