summaryrefslogtreecommitdiff
path: root/spec/unit/plugins/linux/filesystem2_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/plugins/linux/filesystem2_spec.rb')
-rw-r--r--spec/unit/plugins/linux/filesystem2_spec.rb62
1 files changed, 31 insertions, 31 deletions
diff --git a/spec/unit/plugins/linux/filesystem2_spec.rb b/spec/unit/plugins/linux/filesystem2_spec.rb
index e62e9d1a..7006b884 100644
--- a/spec/unit/plugins/linux/filesystem2_spec.rb
+++ b/spec/unit/plugins/linux/filesystem2_spec.rb
@@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
describe Ohai::System, "Linux filesystem plugin" do
let (:plugin) { get_plugin("linux/filesystem2") }
- before(:each) do
+ before do
allow(plugin).to receive(:collect_os).and_return(:linux)
allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
@@ -53,7 +53,7 @@ describe Ohai::System, "Linux filesystem plugin" do
end
describe "when gathering filesystem usage data from df" do
- before(:each) do
+ before do
@stdout = <<-DF
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
@@ -80,55 +80,55 @@ DFi
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
end
- it "should run df -P and df -iP" do
+ it "runs df -P and df -iP" do
expect(plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, ""))
expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
plugin.run
end
- it "should set kb_size to value from df -P" do
+ it "sets kb_size to value from df -P" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057")
end
- it "should set kb_used to value from df -P" do
+ it "sets kb_used to value from df -P" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253")
end
- it "should set kb_available to value from df -P" do
+ it "sets kb_available to value from df -P" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805")
end
- it "should set percent_used to value from df -P" do
+ it "sets percent_used to value from df -P" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%")
end
- it "should set mount to value from df -P" do
+ it "sets mount to value from df -P" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
end
- it "should set total_inodes to value from df -iP" do
+ it "sets total_inodes to value from df -iP" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865")
end
- it "should set inodes_used to value from df -iP" do
+ it "sets inodes_used to value from df -iP" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380")
end
- it "should set inodes_available to value from df -iP" do
+ it "sets inodes_available to value from df -iP" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485")
end
end
describe "when gathering mounted filesystem data from mount" do
- before(:each) do
+ before do
@stdout = <<-MOUNT
/dev/mapper/sys.vg-root.lv on / type ext4 (rw,noatime,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
@@ -149,29 +149,29 @@ MOUNT
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
end
- it "should run mount" do
+ it "runs mount" do
expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
plugin.run
end
- it "should set mount to value from mount" do
+ it "sets mount to value from mount" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
end
- it "should set fs_type to value from mount" do
+ it "sets fs_type to value from mount" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
end
- it "should set mount_options to an array of values from mount" do
+ it "sets mount_options to an array of values from mount" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime})
end
end
describe "when gathering filesystem type data from blkid" do
- before(:each) do
+ before do
# blkid and lsblk output are coorelated with df/mount output, so the
# most full test of them actually requires we have both
@dfstdout = <<-DF
@@ -216,11 +216,11 @@ BLKID_TYPE
allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, ""))
end
- it "should run blkid" do
+ it "runs blkid" do
plugin.run
end
- it "should set kb_size to value from blkid" do
+ it "sets kb_size to value from blkid" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
@@ -229,7 +229,7 @@ BLKID_TYPE
end
describe "when gathering filesystem type data from lsblk" do
- before(:each) do
+ before do
@dfstdout = <<-DF
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
@@ -276,18 +276,18 @@ BLKID_TYPE
and_return(mock_shell_out(0, @stdout, ""))
end
- it "should run lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
+ it "runs lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
plugin.run
end
- it "should set kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
+ it "sets kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
end
- it "should ignore extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
+ it "ignores extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root")
end
@@ -295,7 +295,7 @@ BLKID_TYPE
end
describe "when gathering data from /proc/mounts" do
- before(:each) do
+ before do
allow(File).to receive(:exist?).with("/proc/mounts").and_return(true)
@double_file = double("/proc/mounts")
@mounts = <<-MOUNTS
@@ -326,24 +326,24 @@ MOUNTS
allow(File).to receive(:open).with("/proc/mounts").and_return(@double_file)
end
- it "should set mount to value from /proc/mounts" do
+ it "sets mount to value from /proc/mounts" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
end
- it "should set fs_type to value from /proc/mounts" do
+ it "sets fs_type to value from /proc/mounts" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
end
- it "should set mount_options to an array of values from /proc/mounts" do
+ it "sets mount_options to an array of values from /proc/mounts" do
plugin.run
expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
end
end
describe "when gathering filesystem data with devices mounted more than once" do
- before(:each) do
+ before do
# there's a few different examples one can run into in this output:
# 1. A device physically mounted in more than one place: /home and /home2
# 2. A bind-mounted directory, which shows up as the same device in a
@@ -383,7 +383,7 @@ BLKID_TYPE
and_return(mock_shell_out(0, @stdout, ""))
end
- it "should provide a devices view with all mountpoints" do
+ it "provides a devices view with all mountpoints" do
plugin.run
expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"])
expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"])
@@ -392,7 +392,7 @@ BLKID_TYPE
end
describe "when gathering filesystem data with double-mounts" do
- before(:each) do
+ before do
@dfstdout = <<-DF
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
@@ -429,7 +429,7 @@ BLKID_TYPE
and_return(mock_shell_out(0, @stdout, ""))
end
- it "should provide a mounts view with all devices" do
+ it "provides a mounts view with all devices" do
plugin.run
expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
end