summaryrefslogtreecommitdiff
path: root/spec/unit/plugins/linux/platform_spec.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-26 21:06:48 -0800
committerTim Smith <tsmith@chef.io>2018-11-26 21:06:48 -0800
commit1ce3724e057afaeeca45ce24d313893bd3c944a9 (patch)
treed25e27963fcc5081186ebc2626ea98404d280604 /spec/unit/plugins/linux/platform_spec.rb
parentb6b2d17b2729e991d5073839d8d57b8d2702b3e4 (diff)
downloadohai-1ce3724e057afaeeca45ce24d313893bd3c944a9.tar.gz
Use shellout properly for kernel version detection
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/unit/plugins/linux/platform_spec.rb')
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index 3614d3d8..05d77763 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -238,7 +238,7 @@ OS_DATA
end
it "should set platform_version using kernel version from uname" do
- expect(plugin).to receive(:`).with("/bin/uname -r").and_return("3.18.2-2-ARCH")
+ allow(plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH\n", ""))
plugin.run
expect(plugin[:platform]).to eq("arch")
expect(plugin[:platform_family]).to eq("arch")
@@ -273,12 +273,12 @@ OS_DATA
context "when on centos where version data in os-release is wrong" do
let(:os_data) do
<<~OS_DATA
- NAME="CentOS Linux"
- VERSION="7 (Core)"
- ID="centos"
- ID_LIKE="rhel fedora"
- VERSION_ID="7"
- PRETTY_NAME="CentOS Linux 7 (Core)"
+ NAME="CentOS Linux"
+ VERSION="7 (Core)"
+ ID="centos"
+ ID_LIKE="rhel fedora"
+ VERSION_ID="7"
+ PRETTY_NAME="CentOS Linux 7 (Core)"
OS_DATA
end
@@ -541,6 +541,7 @@ OS_DATA
let(:have_exherbo_release) { true }
before(:each) do
+ allow(plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH\n", ""))
plugin.lsb = nil
end
@@ -551,7 +552,6 @@ OS_DATA
end
it "should set platform_version to kernel release" do
- expect(plugin).to receive(:`).with("/bin/uname -r").and_return("3.18.2-2-ARCH")
plugin.run
expect(plugin[:platform_version]).to eq("3.18.2-2-ARCH")
end