diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-11-11 07:40:04 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-11-11 07:49:54 -0800 |
commit | d37b99dd4493c3f16606e3f63eb3f745aace9180 (patch) | |
tree | 9e7fc044232319e0626a31bdaaa6cbce17ca7357 | |
parent | 0b44eef872de39762b54c82ffbd1d49898115dc2 (diff) | |
download | chef-d37b99dd4493c3f16606e3f63eb3f745aace9180.tar.gz |
Add additional property coerce specs to mountmount_spec
Test the transforms we perform on these inputs
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | spec/unit/resource/mount_spec.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 933c4f1947..c9800f1381 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -49,6 +49,16 @@ describe Chef::Resource::Mount do expect(resource.mount_point).to eql("U:") end + it "splits strings passed to the mount_point property" do + resource.mount_point "U:" + expect(resource.mount_point).to eql("U:") + end + + it "strips trailing slashes from mount_point values" do + resource.mount_point "//192.168.11.102/Share/backup/" + expect(resource.mount_point).to eql("//192.168.11.102/Share/backup") + end + it "raises error when mount_point property is not set" do expect { resource.mount_point nil }.to raise_error(Chef::Exceptions::ValidationFailed, "Property mount_point must be one of: String! You passed nil.") end @@ -87,12 +97,17 @@ describe Chef::Resource::Mount do it "allows options to be sent as a string, and convert to array" do resource.options "rw,noexec" - expect(resource.options).to be_a_kind_of(Array) + expect(resource.options).to eql(%w{rw noexec}) + end + + it "strips whitespace around options in a comma deliminated string" do + resource.options "rw, noexec" + expect(resource.options).to eql(%w{rw noexec}) end it "allows options property as an array" do resource.options %w{ro nosuid} - expect(resource.options).to be_a_kind_of(Array) + expect(resource.options).to eql(%w{ro nosuid}) end it "allows options to be sent as a delayed evaluator" do @@ -102,7 +117,6 @@ describe Chef::Resource::Mount do it "allows options to be sent as a delayed evaluator, and convert to array" do resource.options Chef::DelayedEvaluator.new { "rw,noexec" } - expect(resource.options).to be_a_kind_of(Array) expect(resource.options).to eql(%w{rw noexec}) end |