diff options
author | Thom May <thom@chef.io> | 2018-03-09 18:28:47 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2018-03-14 16:29:48 +0000 |
commit | 61e3d4bb382da5a0f6c09dd144ce4c6fc96c3ca9 (patch) | |
tree | c83baedaba2f265ebc85a4be907ad2c0ea0c26a8 /spec/unit | |
parent | f1c97d18f68b01e8f82757bbb1111ca82d4fba99 (diff) | |
download | chef-61e3d4bb382da5a0f6c09dd144ce4c6fc96c3ca9.tar.gz |
update mount to use properties and fix 6851
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/mount/mount_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/resource/mount_spec.rb | 4 |
2 files changed, 13 insertions, 7 deletions
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 66aa509390..cd663b9684 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -497,26 +497,28 @@ describe Chef::Provider::Mount::Mount do # we should not create two mount lines, but update the existing one context "when the device is described differently" do it "should update the existing line" do + @current_resource.enabled(true) status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1) expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) filesystems = [%q{/dev/sdy1 /tmp/foo ext3 defaults 1 2}, %q{/dev/sdz1 /tmp/foo ext3 defaults 1 2}].join("\n") - fstab = StringIO.new - fstab.puts filesystems + fstab = StringIO.new filesystems + + fstab_write = StringIO.new allow(::File).to receive(:readlines).with("/etc/fstab").and_return(fstab.readlines) - allow(::File).to receive(:open).with("/etc/fstab", "w").and_yield(fstab) - allow(::File).to receive(:open).with("/etc/fstab", "a").and_yield(fstab) + allow(::File).to receive(:open).with("/etc/fstab", "w").and_yield(fstab_write) + allow(::File).to receive(:open).with("/etc/fstab", "a").and_yield(fstab_write) @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" @new_resource.dump 1 @provider.enable_fs - expect(fstab.string).to match(%r{/dev/sdy1\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2}) - expect(fstab.string).to match(%r{UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2}) - expect(fstab.string).not_to match(%r{/dev/sdz1\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2}) + expect(fstab_write.string).to match(%r{/dev/sdy1\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2}) + expect(fstab_write.string).to match(%r{UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2}) + expect(fstab_write.string).not_to match(%r{/dev/sdz1\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2}) end end end diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 41eb9c221f..2d0dc6d91e 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -61,6 +61,10 @@ describe Chef::Resource::Mount do expect(resource.fstype).to eql("nfs") end + it "sets fstype to 'auto' by default" do + expect(resource.fstype).to eql("auto") + end + it "allows you to set the dump attribute" do resource.dump 1 expect(resource.dump).to eql(1) |