summaryrefslogtreecommitdiff
path: root/spec/unit/provider/mount/solaris_spec.rb
blob: 9ac079a11c462e2abf162013673978d73d13266b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
#
# Author:: Lamont Granquist (<lamont@getchef.com>)
# Copyright:: Copyright (c) 2008-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'spec_helper'
require 'ostruct'

describe Chef::Provider::Mount::Solaris do
  let(:node) { Chef::Node.new }

  let(:events) { Chef::EventDispatch::Dispatcher.new }

  let(:run_context) { Chef::RunContext.new(node, {}, events) }

  let(:device_type) { :device }

  let(:fstype) { "ufs" }

  let(:device) { "/dev/dsk/c0t2d0s7" }

  let(:mountpoint) { "/mnt/foo" }

  let(:new_resource) {
    new_resource = Chef::Resource::Mount.new(mountpoint)
    new_resource.device      device
    new_resource.device_type device_type
    new_resource.fstype      fstype

    new_resource.supports :remount => false
    new_resource
  }

  let(:provider) {
    Chef::Provider::Mount::Solaris.new(new_resource, run_context)
  }

  let(:vfstab_file_contents) {
    <<-EOF.gsub /^\s*/, ''
    #device         device          mount           FS      fsck    mount   mount
    #to mount       to fsck         point           type    pass    at boot options
    #
    fd      -       /dev/fd fd      -       no      -
    /proc   -       /proc   proc    -       no      -
    # swap
    /dev/dsk/c0t0d0s1       -       -       swap    -       no      -
    # root
    /dev/dsk/c0t0d0s0       /dev/rdsk/c0t0d0s0      /       ufs     1       no      -
    # tmpfs
    swap    -       /tmp    tmpfs   -       yes     -
    # nfs
    cartman:/share2         -                       /cartman        nfs     -       yes     rw,soft
    # ufs
    /dev/dsk/c0t2d0s7       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
    EOF
  }

  let(:vfstab_file) {
    t = Tempfile.new("rspec-vfstab")
    t.write(vfstab_file_contents)
    t.close
    t
  }

  let(:mount_output) {
    <<-EOF.gsub /^\s*/, ''
    /dev/dsk/c0t0d0s0 on / type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012
    /dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
    EOF
  }

  before do
    stub_const("Chef::Provider::Mount::Solaris::VFSTAB", vfstab_file.path )
    provider.stub(:shell_out!).with("mount -v").and_return(OpenStruct.new(:stdout => mount_output))
    File.stub(:symlink?).with(device).and_return(false)
    File.stub(:exist?).with(device).and_return(true)
    File.stub(:exist?).with(mountpoint).and_return(true)
    expect(File).to_not receive(:exists?)
  end

  describe "#define_resource_requirements" do
    before do
      # we're not testing the actual actions so stub them all out
      [:mount_fs, :umount_fs, :remount_fs, :enable_fs, :disable_fs].each {|m| provider.stub(m) }
    end

    context "when the device_type is :label" do
      let(:device_type) { :label }

      it "should raise an error" do
        expect { provider.define_resource_requirements }.to raise_error(Chef::Exceptions::Mount)
      end
    end

    context "when the device_type is :uuid" do
      let(:device_type) { :uuid }

      it "should raise an error" do
        expect { provider.define_resource_requirements }.to raise_error(Chef::Exceptions::Mount)
      end
    end

    it "run_action(:mount) should raise an error if the device does not exist" do
      File.stub(:exist?).with(device).and_return(false)
      expect { provider.run_action(:mount) }.to raise_error(Chef::Exceptions::Mount)
    end

    it "run_action(:remount) should raise an error if the device does not exist" do
      File.stub(:exist?).with(device).and_return(false)
      expect { provider.run_action(:remount) }.to raise_error(Chef::Exceptions::Mount)
    end

    it "run_action(:mount) should raise an error if the mountpoint does not exist" do
      File.stub(:exist?).with(mountpoint).and_return false
      expect { provider.run_action(:mount) }.to raise_error(Chef::Exceptions::Mount)
    end

    it "run_action(:remount) should raise an error if the mountpoint does not exist" do
      File.stub(:exist?).with(mountpoint).and_return false
      expect { provider.run_action(:remount) }.to raise_error(Chef::Exceptions::Mount)
    end

    %w{tmpfs nfs ctfs proc mntfs objfs sharefs fd smbfs}.each do |ft|
      context "when the device has a fstype of #{ft}" do
        let(:fstype) { ft }
        let(:device) { "something_that_is_not_a_file" }

        before do
          expect(File).to_not receive(:exist?).with(device)
        end

        it "run_action(:mount) should not raise an error" do
          expect { provider.run_action(:mount) }.to_not raise_error
        end

        it "run_action(:remount) should not raise an error" do
          expect { provider.run_action(:remount) }.to_not raise_error
        end
      end
    end

  end

  describe "#load_current_resource" do
    context "when loading a normal UFS filesystem" do

      before do
        provider.load_current_resource
      end

      it "should create a current_resource of type Chef::Resource::Mount" do
        expect(provider.current_resource).to be_a(Chef::Resource::Mount)
      end

      it "should set the name on the current_resource" do
        provider.current_resource.name.should == mountpoint
      end

      it "should set the mount_point on the current_resource" do
        provider.current_resource.mount_point.should == mountpoint
      end

      it "should set the device on the current_resource" do
        provider.current_resource.device.should == device
      end

      it "should set the device_type on the current_resource" do
        provider.current_resource.device_type.should == device_type
      end

      it "should set the mounted status on the current_resource" do
        expect(provider.current_resource.mounted).to be_true
      end

      it "should set the enabled status on the current_resource" do
        expect(provider.current_resource.enabled).to be_true
      end

      it "should set the fstype field on the current_resource" do
        expect(provider.current_resource.fstype).to eql("ufs")
      end

      it "should set the options field on the current_resource" do
        expect(provider.current_resource.options).to eql(["-", "noauto"])
      end

      it "should set the pass field on the current_resource" do
        expect(provider.current_resource.pass).to eql(2)
      end

      it "should not throw an exception when the device does not exist - CHEF-1565" do
        File.stub(:exist?).with(device).and_return(false)
        expect { provider.load_current_resource }.to_not raise_error
      end

      it "should not throw an exception when the mount point does not exist" do
        File.stub(:exist?).with(mountpoint).and_return false
        expect { provider.load_current_resource }.to_not raise_error
      end
    end

    context "when the device is an smbfs mount" do
      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        //solarsystem/tmp on /mnt type smbfs read/write/setuid/devices/dev=5080000 on Tue Mar 29 11:40:18 2011
        EOF
      }
      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        //WORKGROUP;username:password@host/share    -   /mountpoint smbfs   -   no  fileperms=0777,dirperms=0777
        EOF
      }

      it "should work at some point in the future" do
        pending "SMBFS mounts on solaris look like they will need some future code work and more investigation"
      end
    end

    context "when the device is an NFS mount" do
      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        cartman:/share2 on /cartman type nfs rsize=32768,wsize=32768,NFSv4,dev=4000004 on Tue Mar 29 11:40:18 2011
        EOF
      }

      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        cartman:/share2         -                       /cartman        nfs     -       yes     rw,soft
        EOF
      }

      let(:fstype) { "nfs" }

      let(:device) { "cartman:/share2" }

      let(:mountpoint) { "/cartman" }

      before do
        provider.load_current_resource
      end

      it "should set the name on the current_resource" do
        provider.current_resource.name.should == mountpoint
      end

      it "should set the mount_point on the current_resource" do
        provider.current_resource.mount_point.should == mountpoint
      end

      it "should set the device on the current_resource" do
        provider.current_resource.device.should == device
      end

      it "should set the device_type on the current_resource" do
        provider.current_resource.device_type.should == device_type
      end

      it "should set the mounted status on the current_resource" do
        expect(provider.current_resource.mounted).to be_true
      end

      it "should set the enabled status on the current_resource" do
        expect(provider.current_resource.enabled).to be_true
      end

      it "should set the fstype field on the current_resource" do
        expect(provider.current_resource.fstype).to eql("nfs")
      end

      it "should set the options field on the current_resource" do
        expect(provider.current_resource.options).to eql(["rw", "soft", "noauto"])
      end

      it "should set the pass field on the current_resource" do
        # is this correct or should it be nil?
        expect(provider.current_resource.pass).to eql(0)
      end

    end

    context "when the device is symlink" do

      let(:target) { "/dev/mapper/target" }

      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        #{target} on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
        EOF
      }

      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        #{target}       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        EOF
      }

      before do
        File.should_receive(:symlink?).with(device).at_least(:once).and_return(true)
        File.should_receive(:readlink).with(device).at_least(:once).and_return(target)

        provider.load_current_resource()
      end

      it "should set mounted true if the symlink target of the device is found in the mounts list" do
        expect(provider.current_resource.mounted).to be_true
      end

      it "should set enabled true if the symlink target of the device is found in the vfstab" do
        expect(provider.current_resource.enabled).to be_true
      end

      it "should have the correct mount options" do
        expect(provider.current_resource.options).to eql(["-", "noauto"])
      end
    end

    context "when the device is a relative symlink" do
      let(:target) { "foo" }

      let(:absolute_target) { File.expand_path(target, File.dirname(device)) }

      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        #{absolute_target} on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
        EOF
      }

      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        #{absolute_target}       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        EOF
      }

      before do
        File.should_receive(:symlink?).with(device).at_least(:once).and_return(true)
        File.should_receive(:readlink).with(device).at_least(:once).and_return(target)

        provider.load_current_resource()
      end

      it "should set mounted true if the symlink target of the device is found in the mounts list" do
        expect(provider.current_resource.mounted).to be_true
      end

      it "should set enabled true if the symlink target of the device is found in the vfstab" do
        expect(provider.current_resource.enabled).to be_true
      end

      it "should have the correct mount options" do
        expect(provider.current_resource.options).to eql(["-", "noauto"])
      end
    end

    context "when the matching mount point is last in the mounts list" do
      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t0d0s0 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012
        /dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
        EOF
      }
      it "should set mounted true" do
        provider.load_current_resource()
        provider.current_resource.mounted.should be_true
      end
    end

    context "when the matching mount point is not last in the mounts list" do
      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
        /dev/dsk/c0t0d0s0 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012
        EOF
      }
      it "should set mounted false" do
        provider.load_current_resource()
        provider.current_resource.mounted.should be_false
      end
    end

    context "when the matching mount point is not in the mounts list (mountpoint wrong)" do
      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s7 on /mnt/foob type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
        EOF
      }
      it "should set mounted false" do
        provider.load_current_resource()
        provider.current_resource.mounted.should be_false
      end
    end

    context "when the matching mount point is not in the mounts list (raw device wrong)" do
      let(:mount_output) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s72 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
        EOF
      }
      it "should set mounted false" do
        provider.load_current_resource()
        provider.current_resource.mounted.should be_false
      end
    end

    context "when the mount point is last in fstab" do
      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s72       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        /dev/dsk/c0t2d0s7       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        EOF
      }

      it "should set enabled to true" do
        provider.load_current_resource
        provider.current_resource.enabled.should be_true
      end
    end

    context "when the mount point is not last in fstab and is a substring of another mount" do
      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s7       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        /dev/dsk/c0t2d0s72       /dev/rdsk/c0t2d0s7      /mnt/foo/bar            ufs     2       yes     -
        EOF
      }

      it "should set enabled to true" do
        provider.load_current_resource
        provider.current_resource.enabled.should be_true
      end
    end

    context "when the mount point is not last in fstab" do
      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s7       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        /dev/dsk/c0t2d0s72       /dev/rdsk/c0t2d0s72      /mnt/foo            ufs     2       yes     -
        EOF
      }

      it "should set enabled to false" do
        provider.load_current_resource
        provider.current_resource.enabled.should be_false
      end
    end

    context "when the mount point is not in fstab, but the mountpoint is a substring of one that is" do
      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s7       /dev/rdsk/c0t2d0s7      /mnt/foob            ufs     2       yes     -
        EOF
      }

      it "should set enabled to false" do
        provider.load_current_resource
        provider.current_resource.enabled.should be_false
      end
    end

    context "when the mount point is not in fstab, but the device is a substring of one that is" do
      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        /dev/dsk/c0t2d0s72       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        EOF
      }

      it "should set enabled to false" do
        provider.load_current_resource
        provider.current_resource.enabled.should be_false
      end
    end

    context "when the mountpoint line is commented out" do
      let(:vfstab_file_contents) {
        <<-EOF.gsub /^\s*/, ''
        #/dev/dsk/c0t2d0s7       /dev/rdsk/c0t2d0s7      /mnt/foo            ufs     2       yes     -
        EOF
      }

      it "should set enabled to false" do
        provider.load_current_resource
        provider.current_resource.enabled.should be_false
      end
    end
  end

  context "after the mount's state has been discovered" do
    describe "mount_fs" do
      it "should mount the filesystem" do
        provider.should_receive(:shell_out!).with("mount -F #{fstype} -o defaults #{device} #{mountpoint}")
        provider.mount_fs()
      end

      it "should mount the filesystem with options if options were passed" do
        options = "logging,noatime,largefiles,nosuid,rw,quota"
        new_resource.options(options.split(/,/))
        provider.should_receive(:shell_out!).with("mount -F #{fstype} -o #{options} #{device} #{mountpoint}")
        provider.mount_fs()
      end

      it "should delete the 'noauto' magic option" do
        options = "rw,noauto"
        new_resource.options(%w{rw noauto})
        provider.should_receive(:shell_out!).with("mount -F #{fstype} -o rw #{device} #{mountpoint}")
        provider.mount_fs()
      end
    end

    describe "umount_fs" do
      it "should umount the filesystem if it is mounted" do
        provider.should_receive(:shell_out!).with("umount #{mountpoint}")
        provider.umount_fs()
      end
    end

    describe "remount_fs" do
      it "should use mount -o remount" do
        provider.should_receive(:shell_out!).with("mount -o remount #{new_resource.mount_point}")
        provider.remount_fs
      end
    end

    describe "when enabling the fs" do
      it "should enable if enabled isn't true" do
        @current_resource.enabled(false)

        @fstab = StringIO.new
        File.stub(:open).with("/etc/fstab", "a").and_yield(@fstab)
        provider.enable_fs
        @fstab.string.should match(%r{^/dev/sdz1\s+/tmp/foo\s+ext3\s+defaults\s+0\s+2\s*$})
      end

      it "should not enable if enabled is true and resources match" do
        @current_resource.enabled(true)
        @current_resource.fstype("ext3")
        @current_resource.options(["defaults"])
        @current_resource.dump(0)
        @current_resource.pass(2)
        File.should_not_receive(:open).with("/etc/fstab", "a")

        provider.enable_fs
      end

      it "should enable if enabled is true and resources do not match" do
        @current_resource.enabled(true)
        @current_resource.fstype("auto")
        @current_resource.options(["defaults"])
        @current_resource.dump(0)
        @current_resource.pass(2)
        @fstab = StringIO.new
        File.stub(:readlines).and_return([])
        File.should_receive(:open).once.with("/etc/fstab", "w").and_yield(@fstab)
        File.should_receive(:open).once.with("/etc/fstab", "a").and_yield(@fstab)

        provider.enable_fs
      end
    end

    describe "when disabling the fs" do
      it "should disable if enabled is true" do
        @current_resource.enabled(true)

        other_mount = "/dev/sdy1  /tmp/foo  ext3  defaults  1 2\n"
        this_mount = "/dev/sdz1 /tmp/foo  ext3  defaults  1 2\n"

        @fstab_read = [this_mount, other_mount]
        File.stub(:readlines).with("/etc/fstab").and_return(@fstab_read)
        @fstab_write = StringIO.new
        File.stub(:open).with("/etc/fstab", "w").and_yield(@fstab_write)

        provider.disable_fs
        @fstab_write.string.should match(Regexp.escape(other_mount))
        @fstab_write.string.should_not match(Regexp.escape(this_mount))
      end

      it "should disable if enabled is true and ignore commented lines" do
        @current_resource.enabled(true)

        fstab_read = [%q{/dev/sdy1 /tmp/foo  ext3  defaults  1 2},
                      %q{/dev/sdz1 /tmp/foo  ext3  defaults  1 2},
                      %q{#/dev/sdz1 /tmp/foo  ext3  defaults  1 2}]
        fstab_write = StringIO.new

        File.stub(:readlines).with("/etc/fstab").and_return(fstab_read)
        File.stub(:open).with("/etc/fstab", "w").and_yield(fstab_write)

        provider.disable_fs
        fstab_write.string.should match(%r{^/dev/sdy1 /tmp/foo  ext3  defaults  1 2$})
        fstab_write.string.should match(%r{^#/dev/sdz1 /tmp/foo  ext3  defaults  1 2$})
        fstab_write.string.should_not match(%r{^/dev/sdz1 /tmp/foo  ext3  defaults  1 2$})
      end

      it "should disable only the last entry if enabled is true" do
        @current_resource.stub(:enabled).and_return(true)
        fstab_read = ["/dev/sdz1 /tmp/foo  ext3  defaults  1 2\n",
                      "/dev/sdy1 /tmp/foo  ext3  defaults  1 2\n",
                      "/dev/sdz1 /tmp/foo  ext3  defaults  1 2\n"]

        fstab_write = StringIO.new
        File.stub(:readlines).with("/etc/fstab").and_return(fstab_read)
        File.stub(:open).with("/etc/fstab", "w").and_yield(fstab_write)

        provider.disable_fs
        fstab_write.string.should == "/dev/sdz1 /tmp/foo  ext3  defaults  1 2\n/dev/sdy1 /tmp/foo  ext3  defaults  1 2\n"
      end

      it "should not disable if enabled is false" do
        @current_resource.stub(:enabled).and_return(false)

        File.stub(:readlines).with("/etc/fstab").and_return([])
        File.should_not_receive(:open).and_yield(@fstab)

        provider.disable_fs
      end
    end
  end
end