summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-03-24 15:26:09 +0000
committerBryan McLellan <btm@chef.io>2015-03-27 13:36:09 -0700
commit1be4c8a3adccd9e392ca4af48f171763e06aaca9 (patch)
tree960929abc8862daec62ec263518d8357ec6cae80
parent312253ebfd88ac57b8433c2f859690068fe7cb14 (diff)
downloadchef-1be4c8a3adccd9e392ca4af48f171763e06aaca9.tar.gz
Ensure link's path attribute works with delayed
Closes #1769, closes #1767
-rw-r--r--lib/chef/resource/link.rb2
-rw-r--r--spec/unit/resource/link_spec.rb15
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
index 8726eded1d..30f8ec86d1 100644
--- a/lib/chef/resource/link.rb
+++ b/lib/chef/resource/link.rb
@@ -85,7 +85,7 @@ class Chef
# make link quack like a file (XXX: not for public consumption)
def path
- @target_file
+ target_file
end
private
diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb
index 3573a15f31..51221e0472 100644
--- a/spec/unit/resource/link_spec.rb
+++ b/spec/unit/resource/link_spec.rb
@@ -53,6 +53,21 @@ describe Chef::Resource::Link do
expect(@resource.target_file).to eql("fakey_fakerton")
end
+ it "should accept a delayed evaluator as the target path" do
+ @resource.target_file Chef::DelayedEvaluator.new { "my_lazy_name" }
+ expect(@resource.target_file).to eql("my_lazy_name")
+ end
+
+ it "should accept a delayed evaluator when accessing via 'path'" do
+ @resource.target_file Chef::DelayedEvaluator.new { "my_lazy_name" }
+ expect(@resource.path).to eql("my_lazy_name")
+ end
+
+ it "should accept a delayed evaluator via 'to'" do
+ @resource.to Chef::DelayedEvaluator.new { "my_lazy_name" }
+ expect(@resource.to).to eql("my_lazy_name")
+ end
+
it "should accept a string as the link source via 'to'" do
expect { @resource.to "/tmp" }.not_to raise_error
end