diff options
author | Andrea Campi <andrea.campi@zephirworks.com> | 2012-11-18 23:30:22 +0100 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2012-12-14 11:10:28 -0800 |
commit | 77dda3749fb48f0ac4ee3693e21ca0b453c0bbd1 (patch) | |
tree | 4d66431ae29213178e9b358e32209208b4a104d5 /spec/unit/mixin/template_spec.rb | |
parent | 3dd9365d285bd1bd316be6270e108a229595668a (diff) | |
download | chef-77dda3749fb48f0ac4ee3693e21ca0b453c0bbd1.tar.gz |
[CHEF-3249] Add tests to verify that variables passed to a partial properly replace any variable by the same name, but only within that partial.
Diffstat (limited to 'spec/unit/mixin/template_spec.rb')
-rw-r--r-- | spec/unit/mixin/template_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb index aa1dc2f076..a926b1c494 100644 --- a/spec/unit/mixin/template_spec.rb +++ b/spec/unit/mixin/template_spec.rb @@ -108,12 +108,28 @@ describe Chef::Mixin::Template, "render_template" do end end + it "should pass the original variables to partials" do + @template_context[:secret] = 'candy' + + @provider.render_template("before {<%= render 'openldap_variable_stuff.conf.erb' %>} after", @template_context) do |tmp| + tmp.open.read.should == "before {super secret is candy} after" + end + end + it "should pass variables to partials" do @provider.render_template("before {<%= render 'openldap_variable_stuff.conf.erb', :variables => {:secret => 'whatever' } %>} after", @template_context) do |tmp| tmp.open.read.should == "before {super secret is whatever} after" end end + it "should pass variables to partials even if they are named the same" do + @template_context[:secret] = 'one' + + @provider.render_template("before {<%= render 'openldap_variable_stuff.conf.erb', :variables => {:secret => 'two' } %>} after <%= @secret %>", @template_context) do |tmp| + tmp.open.read.should == "before {super secret is two} after one" + end + end + it "should pass nil for missing variables in partials" do @provider.render_template("before {<%= render 'openldap_variable_stuff.conf.erb', :variables => {} %>} after", @template_context) do |tmp| tmp.open.read.should == "before {super secret is } after" |