diff options
| author | Luke Kanies <luke@madstop.com> | 2008-08-07 18:53:02 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-08-09 07:24:25 +1000 |
| commit | 8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94 (patch) | |
| tree | 069c408bf6bdf9189386ea3b121a51b0b420057f /spec/unit/parser | |
| parent | 3ae7eca3928d5dd9d0c93e61ceedc38f60573eb5 (diff) | |
| download | puppet-8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94.tar.gz puppet-8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94.tar.xz puppet-8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94.zip | |
Added tests for TemplateWrapper's use of Scope#to_hash.
We should deprecate the method_missing stuff in 0.25.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/parser')
| -rwxr-xr-x | spec/unit/parser/templatewrapper.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/unit/parser/templatewrapper.rb b/spec/unit/parser/templatewrapper.rb index 40465f955..2d4bd141b 100755 --- a/spec/unit/parser/templatewrapper.rb +++ b/spec/unit/parser/templatewrapper.rb @@ -6,7 +6,7 @@ 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) + @scope = stub('scope', :compiler => compiler, :parser => parser, :to_hash => {}) @file = "fake_template" Puppet::Module.stubs(:find_template).returns("/tmp/fake_template") FileTest.stubs(:exists?).returns("true") @@ -54,4 +54,15 @@ describe Puppet::Parser::TemplateWrapper do tw = Puppet::Parser::TemplateWrapper.new(@scope, @file) tw.has_variable?("chicken").should eql(false) end + + it "should set all of the scope's variables as instance variables" 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) + + @scope.expects(:to_hash).returns("one" => "foo") + @tw.result + + @tw.instance_variable_get("@one").should == "foo" + end end |
