diff options
Diffstat (limited to 'spec/unit/plugins/darwin')
-rw-r--r-- | spec/unit/plugins/darwin/cpu_spec.rb | 22 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/filesystem_spec.rb | 27 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/hardware_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/hostname_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/kernel_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/memory_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/network_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/platform_spec.rb | 18 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/virtualization_spec.rb | 20 |
9 files changed, 62 insertions, 60 deletions
diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb index 75461638..1c0313c4 100644 --- a/spec/unit/plugins/darwin/cpu_spec.rb +++ b/spec/unit/plugins/darwin/cpu_spec.rb @@ -19,7 +19,7 @@ require "spec_helper" describe Ohai::System, "Darwin cpu plugin" do - before(:each) do + before do @plugin = get_plugin("cpu") @stdout = <<~CTL hw.ncpu: 8 @@ -82,43 +82,43 @@ describe Ohai::System, "Darwin cpu plugin" do @plugin.run end - it "should set cpu[:cores] to 4" do + it "sets cpu[:cores] to 4" do expect(@plugin[:cpu][:cores]).to eq(4) end - it "should set cpu[:total] to 8" do + it "sets cpu[:total] to 8" do expect(@plugin[:cpu][:total]).to eq(8) end - it "should set cpu[:real] to 1" do + it "sets cpu[:real] to 1" do expect(@plugin[:cpu][:real]).to eq(1) end - it "should set cpu[:mhz] to 2800" do + it "sets cpu[:mhz] to 2800" do expect(@plugin[:cpu][:mhz]).to eq(2800) end - it "should set cpu[:vendor_id] to GenuineIntel" do + it "sets cpu[:vendor_id] to GenuineIntel" do expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel") end - it "should set cpu[:model_name] to Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz" do + it "sets cpu[:model_name] to Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz" do expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz") end - it "should set cpu[:model] to 70" do + it "sets cpu[:model] to 70" do expect(@plugin[:cpu][:model]).to eq(70) end - it "should set cpu[:family] to 6" do + it "sets cpu[:family] to 6" do expect(@plugin[:cpu][:family]).to eq(6) end - it "should set cpu[:stepping] to 1" do + it "sets cpu[:stepping] to 1" do expect(@plugin[:cpu][:stepping]).to eq(1) end - it "should set cpu[:flags] to array of flags" do + it "sets cpu[:flags] to array of flags" do expect(@plugin[:cpu][:flags]).to eq(["fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "clfsh", "ds", "acpi", "mmx", "fxsr", "sse", "sse2", "ss", "htt", "tm", "pbe", "sse3", "pclmulqdq", "dtes64", "mon", "dscpl", "vmx", "smx", "est", "tm2", "ssse3", "fma", "cx16", "tpr", "pdcm", "sse4.1", "sse4.2", "x2apic", "movbe", "popcnt", "aes", "pcid", "xsave", "osxsave", "seglim64", "tsctmr", "avx1.0", "rdrand", "f16c"]) end end diff --git a/spec/unit/plugins/darwin/filesystem_spec.rb b/spec/unit/plugins/darwin/filesystem_spec.rb index df0c19fc..e971f622 100644 --- a/spec/unit/plugins/darwin/filesystem_spec.rb +++ b/spec/unit/plugins/darwin/filesystem_spec.rb @@ -20,7 +20,8 @@ require "spec_helper" describe Ohai::System, "darwin filesystem plugin" do let(:plugin) { get_plugin("filesystem") } - before(:each) do + + before do allow(plugin).to receive(:collect_os).and_return(:darwin) allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", "")) @@ -28,7 +29,7 @@ describe Ohai::System, "darwin filesystem plugin" do end describe "when gathering filesystem usage data from df" do - before(:each) do + before do @stdout = <<~DF Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% / @@ -41,12 +42,12 @@ describe Ohai::System, "darwin filesystem plugin" do allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, "")) end - it "should run df -i" do + it "runs df -i" do expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set size to value from df -i" do + it "sets size to value from df -i" do plugin.run expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768") expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224") @@ -54,13 +55,13 @@ describe Ohai::System, "darwin filesystem plugin" do expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%") end - it "should set device and mount to value from df -i" do + it "sets device and mount to value from df -i" do plugin.run expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2") end - it "should set inode info to value from df -i" do + it "sets inode info to value from df -i" do plugin.run expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440") expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054") @@ -69,7 +70,7 @@ describe Ohai::System, "darwin filesystem plugin" do end describe "when gathering mounted filesystem data from mount" do - before(:each) do + before do @stdout = <<~MOUNT /dev/disk0s2 on / (hfs, local, journaled) devfs on /dev (devfs, local, nobrowse) @@ -81,12 +82,12 @@ describe Ohai::System, "darwin filesystem plugin" do 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 values from mount" do + it "sets values from mount" do plugin.run expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs") @@ -95,7 +96,7 @@ describe Ohai::System, "darwin filesystem plugin" do end describe "when gathering filesystem data with devices mounted more than once" do - before(:each) do + before do @dfstdout = <<~DF Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% / @@ -109,14 +110,14 @@ describe Ohai::System, "darwin filesystem plugin" do allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) end - it "should provide a devices view with all mountpoints" do + it "provides a devices view with all mountpoints" do plugin.run expect(plugin[:filesystem]["by_device"]["/dev/disk0s2"][:mounts]).to eq(["/", "/another/mountpoint"]) end end describe "when gathering filesystem data with double-mounts" do - before(:each) do + before do @dfstdout = <<~DF Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% / @@ -131,7 +132,7 @@ describe Ohai::System, "darwin filesystem plugin" do allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) end - it "should provide a mounts view with all devices" do + it "provides a mounts view with all devices" do plugin.run expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/disk0s3", "/dev/disk0s4"]) end diff --git a/spec/unit/plugins/darwin/hardware_spec.rb b/spec/unit/plugins/darwin/hardware_spec.rb index 41886cd0..e29b1e2e 100644 --- a/spec/unit/plugins/darwin/hardware_spec.rb +++ b/spec/unit/plugins/darwin/hardware_spec.rb @@ -21,7 +21,8 @@ require_relative "hardware_system_profiler_output" describe Ohai::System, "Darwin hardware plugin", :unix_only do let(:plugin) { get_plugin("darwin/hardware") } - before(:each) do + + before do allow(plugin).to receive(:collect_os).and_return(:darwin) # Make sure it always runs correct commands and mock the data as it calls them allow(plugin).to receive(:shell_out).with( diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb index b0028936..b4ab4ccd 100644 --- a/spec/unit/plugins/darwin/hostname_spec.rb +++ b/spec/unit/plugins/darwin/hostname_spec.rb @@ -19,7 +19,7 @@ require "spec_helper" describe Ohai::System, "Darwin hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") allow(@plugin).to receive(:collect_os).and_return(:darwin) allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", "")) @@ -31,12 +31,12 @@ describe Ohai::System, "Darwin hostname plugin" do it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local") - it "should use #resolve_fqdn to find the fqdn" do + it "uses #resolve_fqdn to find the fqdn" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.bethell") end - it "should set the domain to everything after the first dot of the fqdn" do + it "sets the domain to everything after the first dot of the fqdn" do @plugin.run expect(@plugin[:domain]).to eq("bethell") end diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb index 70d58815..2cf727be 100644 --- a/spec/unit/plugins/darwin/kernel_spec.rb +++ b/spec/unit/plugins/darwin/kernel_spec.rb @@ -19,13 +19,13 @@ require "spec_helper" describe Ohai::System, "Darwin kernel plugin" do - before(:each) do + before do @plugin = get_plugin("kernel") allow(@plugin).to receive(:collect_os).and_return(:darwin) allow(@plugin).to receive(:init_kernel).and_return({}) end - it "should populate kernel[:modules] from `kextstat -k -l`" do + it "populates kernel[:modules] from `kextstat -k -l`" do allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", "")) allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, <<EOF, "")) 8 0 0xffffff7f81aed000 0x41000 0x41000 com.apple.kec.corecrypto (1.0) <7 6 5 4 3 1> @@ -42,21 +42,21 @@ EOF expect(@plugin[:kernel][:modules]).to eql(modules) end - it "should not set kernel_machine to x86_64" do + it "does not set kernel_machine to x86_64" do allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", "")) allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", "")) @plugin.run expect(@plugin[:kernel][:machine]).not_to eq("x86_64") end - it "should set kernel_machine to x86_64" do + it "sets kernel_machine to x86_64" do allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", "")) allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", "")) @plugin.run expect(@plugin[:kernel][:machine]).to eq("x86_64") end - it "should set the kernel_os to the kernel_name value" do + it "sets the kernel_os to the kernel_name value" do allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", "")) allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", "")) @plugin.run diff --git a/spec/unit/plugins/darwin/memory_spec.rb b/spec/unit/plugins/darwin/memory_spec.rb index 07f6fa3e..1baf96d0 100644 --- a/spec/unit/plugins/darwin/memory_spec.rb +++ b/spec/unit/plugins/darwin/memory_spec.rb @@ -19,7 +19,7 @@ require "spec_helper" describe Ohai::System, "Darwin Memory Plugin" do - before(:each) do + before do darwin_memsize = <<~DARWIN_MEMSIZE 17179869184 DARWIN_MEMSIZE @@ -46,19 +46,19 @@ describe Ohai::System, "Darwin Memory Plugin" do @plugin.run end - it "should set memory[:total] to 16384MB" do + it "sets memory[:total] to 16384MB" do expect(@plugin[:memory][:total]).to eq("16384MB") end - it "should set memory[:active] to 5140MB" do + it "sets memory[:active] to 5140MB" do expect(@plugin[:memory][:active]).to eq("5140MB") end - it "should set memory[:inactive] to 738MB" do + it "sets memory[:inactive] to 738MB" do expect(@plugin[:memory][:inactive]).to eq("738MB") end - it "should set memory[:free] to 10504MB" do + it "sets memory[:free] to 10504MB" do expect(@plugin[:memory][:free]).to eq("10504MB") end end diff --git a/spec/unit/plugins/darwin/network_spec.rb b/spec/unit/plugins/darwin/network_spec.rb index d076bc6b..46e53518 100644 --- a/spec/unit/plugins/darwin/network_spec.rb +++ b/spec/unit/plugins/darwin/network_spec.rb @@ -19,7 +19,7 @@ require "spec_helper" describe Ohai::System, "Darwin Network Plugin" do - before(:each) do + before do @darwin_ifconfig = <<~DARWIN_IFCONFIG lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=3<RXCSUM,TXCSUM> @@ -430,7 +430,7 @@ describe Ohai::System, "Darwin Network Plugin" do end describe "gathering IP layer address info" do - before(:each) do + before do allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @darwin_arp, "")) allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @darwin_ifconfig, "")) allow(@plugin).to receive(:shell_out).with("netstat -i -d -l -b -n").and_return(mock_shell_out(0, @darwin_netstat, "")) @@ -549,7 +549,7 @@ describe Ohai::System, "Darwin Network Plugin" do expect(@plugin["network"][:default_gateway]).to eq("10.20.10.1") end - it "should detect network settings" do + it "detects network settings" do expect(@plugin["network"]["settings"]["net.local.stream.sendspace"]).to eq("8192") expect(@plugin["network"]["settings"]["net.local.stream.recvspace"]).to eq("8192") expect(@plugin["network"]["settings"]["net.local.stream.tracemdns"]).to eq("0") diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb index 96184212..ecd2c5f0 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -19,51 +19,51 @@ require "spec_helper" describe Ohai::System, "Darwin plugin platform" do - before(:each) do + before do @plugin = get_plugin("darwin/platform") allow(@plugin).to receive(:collect_os).and_return(:darwin) @stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33" allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, "")) end - it "should run sw_vers" do + it "runs sw_vers" do expect(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, "")) @plugin.run end - it "should set platform to ProductName, downcased with _ for \\s" do + it "sets platform to ProductName, downcased with _ for \\s" do @plugin.run expect(@plugin[:platform]).to eq("mac_os_x") end - it "should set platform_version to ProductVersion" do + it "sets platform_version to ProductVersion" do @plugin.run expect(@plugin[:platform_version]).to eq("10.5.5") end - it "should set platform_build to BuildVersion" do + it "sets platform_build to BuildVersion" do @plugin.run expect(@plugin[:platform_build]).to eq("9F33") end - it "should set platform_family to mac_os_x" do + it "sets platform_family to mac_os_x" do @plugin.run expect(@plugin[:platform_family]).to eq("mac_os_x") end describe "on os x server" do - before(:each) do + before do @plugin[:os] = "darwin" @stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549" allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, "")) end - it "should set platform to mac_os_x_server" do + it "sets platform to mac_os_x_server" do @plugin.run expect(@plugin[:platform]).to eq("mac_os_x_server") end - it "should set platform_family to mac_os_x" do + it "sets platform_family to mac_os_x" do @plugin.run expect(@plugin[:platform_family]).to eq("mac_os_x") end diff --git a/spec/unit/plugins/darwin/virtualization_spec.rb b/spec/unit/plugins/darwin/virtualization_spec.rb index 2fe3ad01..55936c93 100644 --- a/spec/unit/plugins/darwin/virtualization_spec.rb +++ b/spec/unit/plugins/darwin/virtualization_spec.rb @@ -23,7 +23,7 @@ require "spec_helper" describe Ohai::System, "Darwin virtualization platform" do let(:plugin) { get_plugin("darwin/virtualization") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:darwin) allow(plugin).to receive(:prlctl_exists?).and_return(false) allow(plugin).to receive(:ioreg_exists?).and_return(false) @@ -35,12 +35,12 @@ describe Ohai::System, "Darwin virtualization platform" do end describe "when detecting OS X virtualization" do - it "should not set virtualization keys if no binaries are found" do + it "does not set virtualization keys if no binaries are found" do plugin.run expect(plugin[:virtualization]).to eq({ "systems" => {} }) end - it "should set docker host if docker exists" do + it "sets docker host if docker exists" do allow(plugin).to receive(:docker_exists?).and_return(true) plugin.run expect(plugin[:virtualization][:system]).to eq("docker") @@ -48,7 +48,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:docker]).to eq("host") end - it "should set vmware host if /Applications/VMware\ Fusion.app exists" do + it "sets vmware host if /Applications/VMware\ Fusion.app exists" do allow(plugin).to receive(:fusion_exists?).and_return(true) plugin.run expect(plugin[:virtualization][:system]).to eq("vmware") @@ -56,7 +56,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:vmware]).to eq("host") end - it "should set vmware guest if hardware attributes mention vmware" do + it "sets vmware guest if hardware attributes mention vmware" do plugin[:hardware][:boot_rom_version] = "VMW71.00V.6997262.B64.1710270607" plugin.run expect(plugin[:virtualization][:system]).to eq("vmware") @@ -64,7 +64,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:vmware]).to eq("guest") end - it "should set vbox host if /usr/local/bin/VBoxManage exists" do + it "sets vbox host if /usr/local/bin/VBoxManage exists" do allow(plugin).to receive(:vboxmanage_exists?).and_return("/usr/local/bin/VBoxManage") plugin.run expect(plugin[:virtualization][:system]).to eq("vbox") @@ -72,7 +72,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:vbox]).to eq("host") end - it "should set vbox guest if hardware attributes mention virtualbox" do + it "sets vbox guest if hardware attributes mention virtualbox" do plugin[:hardware][:boot_rom_version] = "VirtualBox" plugin.run expect(plugin[:virtualization][:system]).to eq("vbox") @@ -80,7 +80,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:vbox]).to eq("guest") end - it "should set parallels host if /usr/bin/prlctl exists" do + it "sets parallels host if /usr/bin/prlctl exists" do allow(plugin).to receive(:prlctl_exists?).and_return("/usr/bin/prlctl") plugin.run expect(plugin[:virtualization][:system]).to eq("parallels") @@ -88,7 +88,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:parallels]).to eq("host") end - it "should set parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do + it "sets parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do allow(plugin).to receive(:ioreg_exists?).and_return(true) ioreg = <<-IOREG | | +-o pci1ab8,4000@3 <class IOPCIDevice, id 0x1000001d1, registered, matched, active, busy 0 (40 ms), retain 9> @@ -122,7 +122,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:parallels]).to eq("guest") end - it "should not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do + it "does not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do allow(plugin).to receive(:ioreg_exists?).and_return(true) ioreg = <<-IOREG | | +-o pci8086,2445@1F,4 <class IOPCIDevice, id 0x1000001d4, registered, matched, active, busy 0 (974 ms), retain 11> |