summaryrefslogtreecommitdiffstats
path: root/spec/unit/ral
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2008-02-18 11:59:54 -0600
committerRick Bradley <rick@rickbradley.com>2008-02-18 11:59:54 -0600
commit191313405183dceb2010037312fdd2a900711676 (patch)
treefd11098903b518aca16d2d4f96735a676be237e5 /spec/unit/ral
parent6781e1066065fb1044df3c36a6512839dbe1e622 (diff)
downloadpuppet-191313405183dceb2010037312fdd2a900711676.tar.gz
puppet-191313405183dceb2010037312fdd2a900711676.tar.xz
puppet-191313405183dceb2010037312fdd2a900711676.zip
converting mount provider specs from setup/teardown to before/after
Diffstat (limited to 'spec/unit/ral')
-rwxr-xr-xspec/unit/ral/provider/mount.rb172
1 files changed, 84 insertions, 88 deletions
diff --git a/spec/unit/ral/provider/mount.rb b/spec/unit/ral/provider/mount.rb
index 65aaf7053..0b90d53c9 100755
--- a/spec/unit/ral/provider/mount.rb
+++ b/spec/unit/ral/provider/mount.rb
@@ -4,8 +4,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/provider/mount'
-module MountModuleTesting
- def setup
+describe Puppet::Provider::Mount do
+ before :each do
@mounter = Object.new
@mounter.extend(Puppet::Provider::Mount)
@@ -16,119 +16,115 @@ module MountModuleTesting
@mounter.stubs(:resource).returns(@resource)
end
-end
-describe Puppet::Provider::Mount, " when mounting" do
- include MountModuleTesting
+ describe Puppet::Provider::Mount, " when mounting" do
- it "should use the 'mountcmd' method to mount" do
- @mounter.stubs(:options).returns(nil)
- @mounter.expects(:mountcmd)
+ it "should use the 'mountcmd' method to mount" do
+ @mounter.stubs(:options).returns(nil)
+ @mounter.expects(:mountcmd)
- @mounter.mount
- end
+ @mounter.mount
+ end
- it "should flush before mounting if a flush method exists" do
- @mounter.meta_def(:flush) { }
- @mounter.expects(:flush)
- @mounter.stubs(:mountcmd)
- @mounter.stubs(:options).returns(nil)
+ it "should flush before mounting if a flush method exists" do
+ @mounter.meta_def(:flush) { }
+ @mounter.expects(:flush)
+ @mounter.stubs(:mountcmd)
+ @mounter.stubs(:options).returns(nil)
- @mounter.mount
- end
+ @mounter.mount
+ end
- it "should add the options following '-o' if they exist and are not set to :absent" do
- @mounter.stubs(:options).returns("ro")
- @mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" }
+ it "should add the options following '-o' if they exist and are not set to :absent" do
+ @mounter.stubs(:options).returns("ro")
+ @mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" }
- @mounter.mount
- end
+ @mounter.mount
+ end
- it "should specify the filesystem name to the mount command" do
- @mounter.stubs(:options).returns(nil)
- @mounter.expects(:mountcmd).with { |*ary| ary[-1] == @name }
+ it "should specify the filesystem name to the mount command" do
+ @mounter.stubs(:options).returns(nil)
+ @mounter.expects(:mountcmd).with { |*ary| ary[-1] == @name }
- @mounter.mount
+ @mounter.mount
+ end
end
-end
-describe Puppet::Provider::Mount, " when remounting" do
- include MountModuleTesting
-
- it "should use '-o remount' if the resource specifies it supports remounting" do
- @mounter.stubs(:info)
- @resource.stubs(:[]).with(:remounts).returns(:true)
- @mounter.expects(:mountcmd).with("-o", "remount", @name)
- @mounter.remount
+ describe Puppet::Provider::Mount, " when remounting" do
+
+ it "should use '-o remount' if the resource specifies it supports remounting" do
+ @mounter.stubs(:info)
+ @resource.stubs(:[]).with(:remounts).returns(:true)
+ @mounter.expects(:mountcmd).with("-o", "remount", @name)
+ @mounter.remount
+ end
+
+ it "should unmount and mount if the resource does not specify it supports remounting" do
+ @mounter.stubs(:info)
+ @resource.stubs(:[]).with(:remounts).returns(false)
+ @mounter.expects(:unmount)
+ @mounter.expects(:mount)
+ @mounter.remount
+ end
+
+ it "should log that it is remounting" do
+ @resource.stubs(:[]).with(:remounts).returns(:true)
+ @mounter.stubs(:mountcmd)
+ @mounter.expects(:info).with("Remounting")
+ @mounter.remount
+ end
end
- it "should unmount and mount if the resource does not specify it supports remounting" do
- @mounter.stubs(:info)
- @resource.stubs(:[]).with(:remounts).returns(false)
- @mounter.expects(:unmount)
- @mounter.expects(:mount)
- @mounter.remount
- end
+ describe Puppet::Provider::Mount, " when unmounting" do
- it "should log that it is remounting" do
- @resource.stubs(:[]).with(:remounts).returns(:true)
- @mounter.stubs(:mountcmd)
- @mounter.expects(:info).with("Remounting")
- @mounter.remount
+ it "should call the :umount command with the resource name" do
+ @mounter.expects(:umount).with(@name)
+ @mounter.unmount
+ end
end
-end
-describe Puppet::Provider::Mount, " when unmounting" do
- include MountModuleTesting
+ describe Puppet::Provider::Mount, " when determining if it is mounted" do
- it "should call the :umount command with the resource name" do
- @mounter.expects(:umount).with(@name)
- @mounter.unmount
- end
-end
-
-describe Puppet::Provider::Mount, " when determining if it is mounted" do
- include MountModuleTesting
+ it "should parse the results of running the mount command with no arguments" do
+ Facter.stubs(:value).returns("whatever")
+ @mounter.expects(:mountcmd).returns("")
- it "should parse the results of running the mount command with no arguments" do
- Facter.stubs(:value).returns("whatever")
- @mounter.expects(:mountcmd).returns("")
-
- @mounter.mounted?
- end
+ @mounter.mounted?
+ end
- it "should match ' on /private/var/automount<name>' if the operating system is Darwin" do
- Facter.stubs(:value).with("operatingsystem").returns("Darwin")
- @mounter.expects(:mountcmd).returns("/dev/whatever on /private/var/automount/\ndevfs on /dev")
+ it "should match ' on /private/var/automount<name>' if the operating system is Darwin" do
+ Facter.stubs(:value).with("operatingsystem").returns("Darwin")
+ @mounter.expects(:mountcmd).returns("/dev/whatever on /private/var/automount/\ndevfs on /dev")
- @mounter.should be_mounted
- end
+ @mounter.should be_mounted
+ end
- it "should match ' on <name>' if the operating system is Darwin" do
- Facter.stubs(:value).with("operatingsystem").returns("Darwin")
- @mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev")
+ it "should match ' on <name>' if the operating system is Darwin" do
+ Facter.stubs(:value).with("operatingsystem").returns("Darwin")
+ @mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev")
- @mounter.should be_mounted
- end
+ @mounter.should be_mounted
+ end
- it "should match '^<name> on' if the operating system is Solaris" do
- Facter.stubs(:value).with("operatingsystem").returns("Solaris")
- @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
+ it "should match '^<name> on' if the operating system is Solaris" do
+ Facter.stubs(:value).with("operatingsystem").returns("Solaris")
+ @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
- @mounter.should be_mounted
- end
+ @mounter.should be_mounted
+ end
- it "should match ' on <name>' if the operating system is not Darwin or Solaris" do
- Facter.stubs(:value).with("operatingsystem").returns("Debian")
- @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
+ it "should match ' on <name>' if the operating system is not Darwin or Solaris" do
+ Facter.stubs(:value).with("operatingsystem").returns("Debian")
+ @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
- @mounter.should be_mounted
- end
+ @mounter.should be_mounted
+ end
- it "should not be considered mounted if it did not match the mount output" do
- Facter.stubs(:value).with("operatingsystem").returns("Debian")
- @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on /something/else and stuff\n/dev/other/disk on /var and stuff")
+ it "should not be considered mounted if it did not match the mount output" do
+ Facter.stubs(:value).with("operatingsystem").returns("Debian")
+ @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on /something/else and stuff\n/dev/other/disk on /var and stuff")
- @mounter.should_not be_mounted
+ @mounter.should_not be_mounted
+ end
end
end