summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-05-07 14:42:39 -0700
committerSerdar Sutay <serdar@opscode.com>2014-05-07 14:42:39 -0700
commited95df1f261daf9369eaeb113210598981e50d44 (patch)
tree9f12e588707b01bdee8157967ce7eaa9e6586b48
parent8853fa5be37d7c19feffa4d9430958bd4017450f (diff)
parentcdf3870ca0fed162b03b6b27b6ea1daf84593d52 (diff)
downloadchef-ed95df1f261daf9369eaeb113210598981e50d44.tar.gz
Merge pull request #1356 from opscode/ssd/CHEF-5163
[CHEF-5163] Support lazy evaluation the mount resource's options attr
-rw-r--r--lib/chef/resource/mount.rb18
-rw-r--r--spec/unit/resource/mount_spec.rb11
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb
index 49984630c0..507c5329e3 100644
--- a/lib/chef/resource/mount.rb
+++ b/lib/chef/resource/mount.rb
@@ -81,16 +81,17 @@ class Chef
end
def options(arg=nil)
- if arg.is_a?(String)
- converted_arg = arg.gsub(/,/, ' ').split(/ /)
+ ret = set_or_return(
+ :options,
+ arg,
+ :kind_of => [ Array, String ]
+ )
+
+ if ret.is_a? String
+ ret.gsub(/,/, ' ').split(/ /)
else
- converted_arg = arg
+ ret
end
- set_or_return(
- :options,
- converted_arg,
- :kind_of => [ Array ]
- )
end
def dump(arg=nil)
@@ -162,4 +163,3 @@ class Chef
end
end
end
-
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb
index ae00cd9b14..85cabe7dcb 100644
--- a/spec/unit/resource/mount_spec.rb
+++ b/spec/unit/resource/mount_spec.rb
@@ -82,6 +82,17 @@ describe Chef::Resource::Mount do
@resource.options.should be_a_kind_of(Array)
end
+ it "should allow options to be sent as a delayed evaluator" do
+ @resource.options Chef::DelayedEvaluator.new {["rw", "noexec"]}
+ @resource.options.should eql(["rw", "noexec"])
+ end
+
+ it "should allow options to be sent as a delayed evaluator, and convert to array" do
+ @resource.options Chef::DelayedEvaluator.new {"rw,noexec"}
+ @resource.options.should be_a_kind_of(Array)
+ @resource.options.should eql(["rw", "noexec"])
+ end
+
it "should accept true for mounted" do
@resource.mounted(true)
@resource.mounted.should eql(true)