summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/templatewrapper.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-05-17 23:08:40 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-05-18 17:05:26 +1000
commit07ff4be92a1d46fe0f6ec3de3c33b5a3b99be755 (patch)
treeb6337cf6ee22b7e0ace0d1b3a635f1fdacd5fd68 /spec/unit/parser/templatewrapper.rb
parent7ce42daf5a0c2e3946732f7acb1c0ce680dc432e (diff)
downloadpuppet-07ff4be92a1d46fe0f6ec3de3c33b5a3b99be755.tar.gz
puppet-07ff4be92a1d46fe0f6ec3de3c33b5a3b99be755.tar.xz
puppet-07ff4be92a1d46fe0f6ec3de3c33b5a3b99be755.zip
Fixing #2250 - Missing templates throw a helpful error
This changes the behaviour of template searching a bit - we previously usually returned a file name, whether the template existed or not. Now we only return a path if it exists. Refactoring a few of the the tests for TemplateWrapper, also. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/parser/templatewrapper.rb')
-rwxr-xr-xspec/unit/parser/templatewrapper.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/spec/unit/parser/templatewrapper.rb b/spec/unit/parser/templatewrapper.rb
index ce458af75..a72595279 100755
--- a/spec/unit/parser/templatewrapper.rb
+++ b/spec/unit/parser/templatewrapper.rb
@@ -22,12 +22,17 @@ describe Puppet::Parser::TemplateWrapper do
it "should check template file existance and read its content" do
Puppet::Parser::Files.expects(:find_template).with("fake_template", "foo").returns("/tmp/fake_template")
- FileTest.expects(:exists?).with("/tmp/fake_template").returns(true)
File.expects(:read).with("/tmp/fake_template").returns("template content")
@tw.file = @file
end
+ it "should fail if a template cannot be found" do
+ Puppet::Parser::Files.expects(:find_template).with("fake_template", "foo").returns nil
+
+ lambda { @tw.file = @file }.should raise_error(Puppet::ParseError)
+ end
+
it "should turn into a string like template[name] for file based template" do
@tw.file = @file
@tw.to_s.should eql("template[/tmp/fake_template]")