summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-05-13 11:58:33 -0500
committerLuke Kanies <luke@madstop.com>2008-05-13 11:58:33 -0500
commit59b9958712d033bbd294ff6469ea3a242c45c82c (patch)
tree974e6671d0de94c805d8e1b5c1c53701d301b816
parent49dde1187e8caea10af63ec1f92e19c0e5f1a595 (diff)
downloadpuppet-59b9958712d033bbd294ff6469ea3a242c45c82c.tar.gz
puppet-59b9958712d033bbd294ff6469ea3a242c45c82c.tar.xz
puppet-59b9958712d033bbd294ff6469ea3a242c45c82c.zip
Correcting whitespace in the templatewrapper code.
Also slightly modified the wording of some of the tests.
-rw-r--r--lib/puppet/parser/templatewrapper.rb12
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/templatewrapper.rb104
2 files changed, 58 insertions, 58 deletions
diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb
index 4f044befc..4790cea30 100644
--- a/lib/puppet/parser/templatewrapper.rb
+++ b/lib/puppet/parser/templatewrapper.rb
@@ -19,14 +19,14 @@ class Puppet::Parser::TemplateWrapper
@scope.parser.watch_file(@file)
end
end
-
+
# Should return true if a variable is defined, false if it is not
def has_variable?(name)
- if @scope.lookupvar(name.to_s, false) != :undefined
- true
- else
- false
- end
+ if @scope.lookupvar(name.to_s, false) != :undefined
+ true
+ else
+ false
+ end
end
# Ruby treats variables like methods, so we can cheat here and
diff --git a/spec/unit/parser/templatewrapper.rb b/spec/unit/parser/templatewrapper.rb
index 76fed3950..40465f955 100644..100755
--- a/spec/unit/parser/templatewrapper.rb
+++ b/spec/unit/parser/templatewrapper.rb
@@ -3,55 +3,55 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe Puppet::Parser::TemplateWrapper do
- before(:each) do
- compiler = stub('compiler', :environment => "foo")
- parser = stub('parser', :watch_file => true)
- @scope = stub('scope', :compiler => compiler, :parser => parser)
- @file = "fake_template"
- Puppet::Module.stubs(:find_template).returns("/tmp/fake_template")
- FileTest.stubs(:exists?).returns("true")
- @tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
- end
-
- it "should create a new object TemplateWrapper from a scope and a file" do
- Puppet::Module.expects(:find_template).with("fake_template", "foo").returns("/tmp/fake_template")
- FileTest.expects(:exists?).with("/tmp/fake_template").returns(true)
- tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
- tw.should be_a_kind_of(Puppet::Parser::TemplateWrapper)
- end
-
- it "should turn in to a string like template[name]" do
- @tw.to_s.should eql("template[/tmp/fake_template]")
- end
-
- it "should return the processed template contents with a call to result" do
- template_mock = mock("template", :result => "woot!")
- File.expects(:read).with("/tmp/fake_template").returns("template contents")
- ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
- @tw.result.should eql("woot!")
- end
-
- it "should return the contents of a variable if called as via method_missing" do
- @scope.expects(:lookupvar).with("chicken", false).returns("is good")
- tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
- tw.chicken.should eql("is good")
- end
-
- it "should throw an exception if a variable is called via method_missing and it does not exist" do
- @scope.expects(:lookupvar).with("chicken", false).returns(:undefined)
- tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
- lambda { tw.chicken }.should raise_error(Puppet::ParseError)
- end
-
- it "should allow you to check whether a variable is defined with has_variable?" do
- @scope.expects(:lookupvar).with("chicken", false).returns("is good")
- tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
- tw.has_variable?("chicken").should eql(true)
- end
-
- it "should allow you to check whether a variable is not defiend with has_variable?" do
- @scope.expects(:lookupvar).with("chicken", false).returns(:undefined)
- tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
- tw.has_variable?("chicken").should eql(false)
- end
-end \ No newline at end of file
+ before(:each) do
+ compiler = stub('compiler', :environment => "foo")
+ parser = stub('parser', :watch_file => true)
+ @scope = stub('scope', :compiler => compiler, :parser => parser)
+ @file = "fake_template"
+ Puppet::Module.stubs(:find_template).returns("/tmp/fake_template")
+ FileTest.stubs(:exists?).returns("true")
+ @tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
+ end
+
+ it "should create a new object TemplateWrapper from a scope and a file" do
+ Puppet::Module.expects(:find_template).with("fake_template", "foo").returns("/tmp/fake_template")
+ FileTest.expects(:exists?).with("/tmp/fake_template").returns(true)
+ tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
+ tw.should be_a_kind_of(Puppet::Parser::TemplateWrapper)
+ end
+
+ it "should turn into a string like template[name]" do
+ @tw.to_s.should eql("template[/tmp/fake_template]")
+ end
+
+ it "should return the processed template contents with a call to result" do
+ template_mock = mock("template", :result => "woot!")
+ File.expects(:read).with("/tmp/fake_template").returns("template contents")
+ ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
+ @tw.result.should eql("woot!")
+ end
+
+ it "should return the contents of a variable if called via method_missing" do
+ @scope.expects(:lookupvar).with("chicken", false).returns("is good")
+ tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
+ tw.chicken.should eql("is good")
+ end
+
+ it "should throw an exception if a variable is called via method_missing and it does not exist" do
+ @scope.expects(:lookupvar).with("chicken", false).returns(:undefined)
+ tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
+ lambda { tw.chicken }.should raise_error(Puppet::ParseError)
+ end
+
+ it "should allow you to check whether a variable is defined with has_variable?" do
+ @scope.expects(:lookupvar).with("chicken", false).returns("is good")
+ tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
+ tw.has_variable?("chicken").should eql(true)
+ end
+
+ it "should allow you to check whether a variable is not defined with has_variable?" do
+ @scope.expects(:lookupvar).with("chicken", false).returns(:undefined)
+ tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
+ tw.has_variable?("chicken").should eql(false)
+ end
+end