diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-05-07 14:42:39 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-05-07 14:42:39 -0700 |
commit | ed95df1f261daf9369eaeb113210598981e50d44 (patch) | |
tree | 9f12e588707b01bdee8157967ce7eaa9e6586b48 | |
parent | 8853fa5be37d7c19feffa4d9430958bd4017450f (diff) | |
parent | cdf3870ca0fed162b03b6b27b6ea1daf84593d52 (diff) | |
download | chef-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.rb | 18 | ||||
-rw-r--r-- | spec/unit/resource/mount_spec.rb | 11 |
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) |