summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2017-04-03 23:02:04 -0500
committerNoah Kantrowitz <noah@coderanger.net>2017-04-03 23:02:04 -0500
commit2c6a8ead5225a44d334dcc70c33308ad7c7a0021 (patch)
tree9b6938d67ff3f47dcc3186f3f5d98ea491546d4f /spec/functional
parente3b9e67a880bcd658517f90a6add837c0e026798 (diff)
downloadchef-2c6a8ead5225a44d334dcc70c33308ad7c7a0021.tar.gz
Allow lazy{} to be used in template resource variables.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/resource/template_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index 32529fbb0c..7f23528821 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -209,4 +209,27 @@ describe Chef::Resource::Template do
end
end
+ describe "when template variables contain lazy{} calls" do
+ it "resolves the DelayedEvaluator" do
+ resource.source("openldap_variable_stuff.conf.erb")
+ resource.variables(:secret => Chef::DelayedEvaluator.new { "nutella" })
+ resource.run_action(:create)
+ expect(IO.read(path)).to eq("super secret is nutella")
+ end
+
+ it "does not mutate the resource variables" do
+ resource.source("openldap_variable_stuff.conf.erb")
+ resource.variables(:secret => Chef::DelayedEvaluator.new { "nutella" })
+ resource.run_action(:create)
+ expect(resource.variables[:secret]).to be_a Chef::DelayedEvaluator
+ end
+
+ it "resolves the DelayedEvaluator when deeply nested" do
+ resource.source("openldap_nested_variable_stuff.erb")
+ resource.variables(:secret => [{"key" => Chef::DelayedEvaluator.new { "nutella" }}])
+ resource.run_action(:create)
+ expect(IO.read(path)).to eq("super secret is nutella")
+ end
+ end
+
end