summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/resource_template_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/util/resource_template_spec.rb')
-rwxr-xr-xspec/unit/util/resource_template_spec.rb78
1 files changed, 39 insertions, 39 deletions
diff --git a/spec/unit/util/resource_template_spec.rb b/spec/unit/util/resource_template_spec.rb
index b4d529e5d..2eab2cfcb 100755
--- a/spec/unit/util/resource_template_spec.rb
+++ b/spec/unit/util/resource_template_spec.rb
@@ -5,54 +5,54 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/util/resource_template'
describe Puppet::Util::ResourceTemplate do
- describe "when initializing" do
- it "should fail if the template does not exist" do
- FileTest.expects(:exist?).with("/my/template").returns false
- lambda { Puppet::Util::ResourceTemplate.new("/my/template", mock('resource')) }.should raise_error(ArgumentError)
- end
-
- it "should not create the ERB template" do
- ERB.expects(:new).never
- FileTest.expects(:exist?).with("/my/template").returns true
- Puppet::Util::ResourceTemplate.new("/my/template", mock('resource'))
- end
+ describe "when initializing" do
+ it "should fail if the template does not exist" do
+ FileTest.expects(:exist?).with("/my/template").returns false
+ lambda { Puppet::Util::ResourceTemplate.new("/my/template", mock('resource')) }.should raise_error(ArgumentError)
end
- describe "when evaluating" do
- before do
- FileTest.stubs(:exist?).returns true
- File.stubs(:read).returns "eh"
+ it "should not create the ERB template" do
+ ERB.expects(:new).never
+ FileTest.expects(:exist?).with("/my/template").returns true
+ Puppet::Util::ResourceTemplate.new("/my/template", mock('resource'))
+ end
+ end
- @template = stub 'template', :result => nil
- ERB.stubs(:new).returns @template
+ describe "when evaluating" do
+ before do
+ FileTest.stubs(:exist?).returns true
+ File.stubs(:read).returns "eh"
- @resource = mock 'resource'
- @wrapper = Puppet::Util::ResourceTemplate.new("/my/template", @resource)
- end
+ @template = stub 'template', :result => nil
+ ERB.stubs(:new).returns @template
- it "should set all of the resource's parameters as instance variables" do
- @resource.expects(:to_hash).returns(:one => "uno", :two => "dos")
- @template.expects(:result).with do |bind|
- eval("@one", bind) == "uno" and eval("@two", bind) == "dos"
- end
- @wrapper.evaluate
- end
+ @resource = mock 'resource'
+ @wrapper = Puppet::Util::ResourceTemplate.new("/my/template", @resource)
+ end
- it "should create a template instance with the contents of the file" do
- File.expects(:read).with("/my/template").returns "yay"
- ERB.expects(:new).with("yay", 0, "-").returns(@template)
+ it "should set all of the resource's parameters as instance variables" do
+ @resource.expects(:to_hash).returns(:one => "uno", :two => "dos")
+ @template.expects(:result).with do |bind|
+ eval("@one", bind) == "uno" and eval("@two", bind) == "dos"
+ end
+ @wrapper.evaluate
+ end
- @wrapper.stubs :set_resource_variables
+ it "should create a template instance with the contents of the file" do
+ File.expects(:read).with("/my/template").returns "yay"
+ ERB.expects(:new).with("yay", 0, "-").returns(@template)
- @wrapper.evaluate
- end
+ @wrapper.stubs :set_resource_variables
+
+ @wrapper.evaluate
+ end
- it "should return the result of the template" do
- @wrapper.stubs :set_resource_variables
+ it "should return the result of the template" do
+ @wrapper.stubs :set_resource_variables
- @wrapper.expects(:binding).returns "mybinding"
- @template.expects(:result).with("mybinding").returns "myresult"
- @wrapper.evaluate.should == "myresult"
- end
+ @wrapper.expects(:binding).returns "mybinding"
+ @template.expects(:result).with("mybinding").returns "myresult"
+ @wrapper.evaluate.should == "myresult"
end
+ end
end