summaryrefslogtreecommitdiff
path: root/spec/unit/provider/mount/mount_spec.rb
diff options
context:
space:
mode:
authorKristian Vlaardingerbroek <kristian.vlaardingerbroek@gmail.com>2013-02-02 16:15:07 +0100
committerBryan McLellan <btm@opscode.com>2013-04-12 11:49:11 -0700
commitf4b6168b6370647024a059036c8310e576258246 (patch)
tree7f65ab238bfe9479ac34b7e217a33f73688c8c14 /spec/unit/provider/mount/mount_spec.rb
parent82f099ce46de029ee756cc497910262262c15b61 (diff)
downloadchef-f4b6168b6370647024a059036c8310e576258246.tar.gz
Add comment to regular expression and add unit tests
Diffstat (limited to 'spec/unit/provider/mount/mount_spec.rb')
-rw-r--r--spec/unit/provider/mount/mount_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index c497a08e40..f6c6c1b7d4 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -216,6 +216,32 @@ describe Chef::Provider::Mount::Mount do
@provider.load_current_resource
@provider.current_resource.enabled.should be_false
end
+
+ it "should not mangle the mount options if the device in fstab is a symlink" do
+ target = "/dev/mapper/target"
+ options = "rw,noexec,noauto"
+
+ ::File.stub!(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub!(:readlink).with("#{@new_resource.device}").and_return(target)
+
+ fstab = "#{@new_resource.device} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n"
+ ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ @provider.load_current_resource
+ @provider.current_resource.options.should eq(options.split(','))
+ end
+
+ it "should not mangle the mount options if the symlink target is in fstab" do
+ target = "/dev/mapper/target"
+ options = "rw,noexec,noauto"
+
+ ::File.stub!(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub!(:readlink).with("#{@new_resource.device}").and_return(target)
+
+ fstab = "#{target} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n"
+ ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ @provider.load_current_resource
+ @provider.current_resource.options.should eq(options.split(','))
+ end
end
context "after the mount's state has been discovered" do