summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/templatewrapper_spec.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2011-06-08 07:03:54 -0700
committerLuke Kanies <luke@puppetlabs.com>2011-07-15 11:51:49 -0700
commit0d2e0672eb516a1b1f2ced6b8c74bd2064dd205e (patch)
tree28d38def94814fcce50b4d82984265dcca7e0545 /spec/unit/parser/templatewrapper_spec.rb
parent4ad404ee7e7244d94ff4d87effc1a041d65b3f73 (diff)
downloadpuppet-0d2e0672eb516a1b1f2ced6b8c74bd2064dd205e.tar.gz
puppet-0d2e0672eb516a1b1f2ced6b8c74bd2064dd205e.tar.xz
puppet-0d2e0672eb516a1b1f2ced6b8c74bd2064dd205e.zip
Adding []/[]= support to Scope
The interface to scope is much clearer this way anyway, but this is needed to integrate Puppet with Hiera[1]. It just provides hash-like behavior to Scope, which Hiera and others can now easily rely on. I also went through all of the code that used Scope#lookupvar and Scope#setvar and changed it if possible, and at the same time cleaned up a lot of tests that were unnecessarily stubbing (and thus making it difficult to tell if I had actually broken anything). 1 - https://github.com/ripienaar/hiera Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'spec/unit/parser/templatewrapper_spec.rb')
-rwxr-xr-xspec/unit/parser/templatewrapper_spec.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/spec/unit/parser/templatewrapper_spec.rb b/spec/unit/parser/templatewrapper_spec.rb
index 600293bbf..6080346fb 100755
--- a/spec/unit/parser/templatewrapper_spec.rb
+++ b/spec/unit/parser/templatewrapper_spec.rb
@@ -72,25 +72,23 @@ describe Puppet::Parser::TemplateWrapper do
end
it "should return the contents of a variable if called via method_missing" do
- @scope.expects(:lookupvar).with { |name,options| name == "chicken"}.returns("is good")
+ @scope["chicken"] = "is good"
tw = Puppet::Parser::TemplateWrapper.new(@scope)
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 { |name,options| name == "chicken"}.returns(:undefined)
tw = Puppet::Parser::TemplateWrapper.new(@scope)
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 { |name,options| name == "chicken"}.returns("is good")
+ @scope["chicken"] = "is good"
tw = Puppet::Parser::TemplateWrapper.new(@scope)
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 { |name,options| name == "chicken"}.returns(:undefined)
tw = Puppet::Parser::TemplateWrapper.new(@scope)
tw.has_variable?("chicken").should eql(false)
end