summaryrefslogtreecommitdiff
path: root/spec/unit/provider/mount/mount_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-01-29 14:17:47 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-01-29 14:17:47 -0800
commitb19b7d000887209f9d8dc1dc6aa468a0497a7391 (patch)
tree68d1eb6c136df20c2800f1dddb4e2c1ed5d75a42 /spec/unit/provider/mount/mount_spec.rb
parentb5c9c6afdfd83fe3f1bf4c991daffeff94b49750 (diff)
downloadchef-b19b7d000887209f9d8dc1dc6aa468a0497a7391.tar.gz
s/stub!/stub/g
fix deprecation warnings
Diffstat (limited to 'spec/unit/provider/mount/mount_spec.rb')
-rw-r--r--spec/unit/provider/mount/mount_spec.rb88
1 files changed, 44 insertions, 44 deletions
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 38b907749e..2c304980d8 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -34,16 +34,16 @@ describe Chef::Provider::Mount::Mount do
@provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context)
- ::File.stub!(:exists?).with("/dev/sdz1").and_return true
- ::File.stub!(:exists?).with("/tmp/foo").and_return true
- ::File.stub!(:realpath).with("/dev/sdz1").and_return "/dev/sdz1"
- ::File.stub!(:realpath).with("/tmp/foo").and_return "/tmp/foo"
+ ::File.stub(:exists?).with("/dev/sdz1").and_return true
+ ::File.stub(:exists?).with("/tmp/foo").and_return true
+ ::File.stub(:realpath).with("/dev/sdz1").and_return "/dev/sdz1"
+ ::File.stub(:realpath).with("/tmp/foo").and_return "/tmp/foo"
end
describe "when discovering the current fs state" do
before do
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => ''))
- ::File.stub!(:foreach).with("/etc/fstab")
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => ''))
+ ::File.stub(:foreach).with("/etc/fstab")
end
it "should create a current resource with the same mount point and device" do
@@ -72,7 +72,7 @@ describe Chef::Provider::Mount::Mount do
it "should ignore trailing slash and set mounted to true for network mount (#{type})" do
@new_resource.device fs_spec
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
@provider.load_current_resource
@provider.current_resource.mounted.should be_true
end
@@ -80,12 +80,12 @@ describe Chef::Provider::Mount::Mount do
end
it "should raise an error if the mount device does not exist" do
- ::File.stub!(:exists?).with("/dev/sdz1").and_return false
+ ::File.stub(:exists?).with("/dev/sdz1").and_return false
lambda { @provider.load_current_resource();@provider.mountable? }.should raise_error(Chef::Exceptions::Mount)
end
it "should not call mountable? with load_current_resource - CHEF-1565" do
- ::File.stub!(:exists?).with("/dev/sdz1").and_return false
+ ::File.stub(:exists?).with("/dev/sdz1").and_return false
@provider.should_receive(:mounted?).and_return(true)
@provider.should_receive(:enabled?).and_return(true)
@provider.should_not_receive(:mountable?)
@@ -103,7 +103,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should raise an error if the mount point does not exist" do
- ::File.stub!(:exists?).with("/tmp/foo").and_return false
+ ::File.stub(:exists?).with("/tmp/foo").and_return false
lambda { @provider.load_current_resource();@provider.mountable? }.should raise_error(Chef::Exceptions::Mount)
end
@@ -125,7 +125,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should set mounted true if the mount point is found in the mounts list" do
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => '/dev/sdz1 on /tmp/foo'))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => '/dev/sdz1 on /tmp/foo'))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_true
end
@@ -133,10 +133,10 @@ describe Chef::Provider::Mount::Mount do
it "should set mounted true if the symlink target of the device is found in the mounts list" do
target = "/dev/mapper/target"
- ::File.stub!(:symlink?).with("#{@new_resource.device}").and_return(true)
- ::File.stub!(:readlink).with("#{@new_resource.device}").and_return(target)
+ ::File.stub(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub(:readlink).with("#{@new_resource.device}").and_return(target)
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/mapper/target on /tmp/foo type ext3 (rw)\n"))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/mapper/target on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_true
end
@@ -145,7 +145,7 @@ describe Chef::Provider::Mount::Mount do
mount = "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_true
end
@@ -154,13 +154,13 @@ describe Chef::Provider::Mount::Mount do
mount = "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_false
end
it "mounted should be false if the mount point is not found in the mounts list" do
- @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
@provider.current_resource.mounted.should be_false
end
@@ -169,7 +169,7 @@ describe Chef::Provider::Mount::Mount do
fstab1 = "/dev/sdy1 /tmp/foo ext3 defaults 1 2\n"
fstab2 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
+ ::File.stub(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
@provider.load_current_resource
@provider.current_resource.enabled.should be_true
@@ -179,7 +179,7 @@ describe Chef::Provider::Mount::Mount do
fstab1 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
fstab2 = "/dev/sdy1 /tmp/foo/bar ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
+ ::File.stub(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2)
@provider.load_current_resource
@provider.current_resource.enabled.should be_true
@@ -188,12 +188,12 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to true if the symlink target is in fstab" do
target = "/dev/mapper/target"
- ::File.stub!(:symlink?).with("#{@new_resource.device}").and_return(true)
- ::File.stub!(:readlink).with("#{@new_resource.device}").and_return(target)
+ ::File.stub(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub(:readlink).with("#{@new_resource.device}").and_return(target)
fstab = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.enabled.should be_true
@@ -201,7 +201,7 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to false if the mount point is not in fstab" do
fstab = "/dev/sdy1 #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.enabled.should be_false
@@ -209,7 +209,7 @@ describe Chef::Provider::Mount::Mount do
it "should ignore commented lines in fstab " do
fstab = "\# #{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.enabled.should be_false
@@ -218,7 +218,7 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to false if the mount point is not last in fstab" do
line_1 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
line_2 = "/dev/sdy1 #{@new_resource.mount_point} ext3 defaults 1 2\n"
- ::File.stub!(:foreach).with("/etc/fstab").and_yield(line_1).and_yield(line_2)
+ ::File.stub(:foreach).with("/etc/fstab").and_yield(line_1).and_yield(line_2)
@provider.load_current_resource
@provider.current_resource.enabled.should be_false
@@ -228,11 +228,11 @@ describe Chef::Provider::Mount::Mount 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)
+ ::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
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.options.should eq(options.split(','))
end
@@ -241,11 +241,11 @@ describe Chef::Provider::Mount::Mount 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)
+ ::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
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
@provider.current_resource.options.should eq(options.split(','))
end
@@ -279,15 +279,15 @@ describe Chef::Provider::Mount::Mount do
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
@new_resource.device_type :uuid
@stdout_findfs = mock("STDOUT", :first => "/dev/sdz1")
- @provider.stub!(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status)
+ @provider.stub(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status)
@stdout_mock = mock('stdout mock')
- @stdout_mock.stub!(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}")
+ @stdout_mock.stub(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}")
@provider.should_receive(:shell_out!).with("mount -t #{@new_resource.fstype} -o defaults -U #{@new_resource.device} #{@new_resource.mount_point}").and_return(@stdout_mock)
@provider.mount_fs()
end
it "should not mount the filesystem if it is mounted" do
- @current_resource.stub!(:mounted).and_return(true)
+ @current_resource.stub(:mounted).and_return(true)
@provider.should_not_receive(:shell_out!)
@provider.mount_fs()
end
@@ -339,7 +339,7 @@ describe Chef::Provider::Mount::Mount do
@current_resource.enabled(false)
@fstab = StringIO.new
- ::File.stub!(:open).with("/etc/fstab", "a").and_yield(@fstab)
+ ::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
@@ -378,9 +378,9 @@ describe Chef::Provider::Mount::Mount do
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)
+ ::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)
+ ::File.stub(:open).with("/etc/fstab", "w").and_yield(@fstab_write)
@provider.disable_fs
@fstab_write.string.should match(Regexp.escape(other_mount))
@@ -395,8 +395,8 @@ describe Chef::Provider::Mount::Mount do
%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)
+ ::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$})
@@ -405,23 +405,23 @@ describe Chef::Provider::Mount::Mount do
end
it "should disable only the last entry if enabled is true" do
- @current_resource.stub!(:enabled).and_return(true)
+ @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)
+ ::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)
+ @current_resource.stub(:enabled).and_return(false)
- ::File.stub!(:readlines).with("/etc/fstab").and_return([])
+ ::File.stub(:readlines).with("/etc/fstab").and_return([])
::File.should_not_receive(:open).and_yield(@fstab)
@provider.disable_fs