summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2018-10-03 12:18:05 -0700
committerPhil Dibowitz <phil@ipom.com>2018-10-03 21:59:20 -0700
commitb5145769e308a91824068dc495127959577e16bb (patch)
treed9d94d75fd8d9092ee4f000634e9a917321a263c /spec
parent54c256ca65bec2f33648cf6b7a7c6c7ec41d125b (diff)
downloadohai-b5145769e308a91824068dc495127959577e16bb.tar.gz
Unify the OS plugins
Utilize the Ohai 7 syntax to keep the code for all these variations of the plugin in the same place and consistent. Signed-off-by: Phil Dibowitz <phil@ipom.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/plugins/aix/os_spec.rb35
-rw-r--r--spec/unit/plugins/freebsd/os_spec.rb32
-rw-r--r--spec/unit/plugins/os_spec.rb33
3 files changed, 33 insertions, 67 deletions
diff --git a/spec/unit/plugins/aix/os_spec.rb b/spec/unit/plugins/aix/os_spec.rb
deleted file mode 100644
index 0a5a8acf..00000000
--- a/spec/unit/plugins/aix/os_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Author:: Isa Farnik (<isa@chef.io>)
-# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require_relative "../../../spec_helper.rb"
-
-describe Ohai::System, "AIX os plugin" do
- before(:each) do
- @plugin = get_plugin("aix/os")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- allow(@plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil))
- @plugin.run
- end
-
- it "should set the top-level os attribute" do
- expect(@plugin[:os]).to eql(:aix)
- end
-
- it "should set the top-level os_level attribute" do
- expect(@plugin[:os_version]).to eql("7200-00-01-1543")
- end
-end
diff --git a/spec/unit/plugins/freebsd/os_spec.rb b/spec/unit/plugins/freebsd/os_spec.rb
deleted file mode 100644
index 3fffb75a..00000000
--- a/spec/unit/plugins/freebsd/os_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Author:: Richard Manyanza (<liseki@nyikacraftsmen.com>)
-# Copyright:: Copyright (c) 2014 Richard Manyanza.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require_relative "../../../spec_helper.rb"
-
-describe Ohai::System, "FreeBSD plugin os" do
- before(:each) do
- @plugin = get_plugin("freebsd/os")
- allow(@plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
- end
-
- it "should set os_version to __FreeBSD_version" do
- @plugin.run
- expect(@plugin[:os_version]).to eq("902001")
- end
-end
diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb
index 89fde46e..f054757b 100644
--- a/spec/unit/plugins/os_spec.rb
+++ b/spec/unit/plugins/os_spec.rb
@@ -1,6 +1,9 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
+# Author:: Richard Manyanza (<liseki@nyikacraftsmen.com>)
+# Author:: Isa Farnik (<isa@chef.io>)
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
+# Copyright:: Copyright (c) 2014 Richard Manyanza.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,6 +72,36 @@ describe Ohai::System, "plugin os" do
end
end
+ describe "on AIX" do
+ before(:each) do
+ @plugin = get_plugin("os")
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
+ allow(@plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil))
+ @plugin.run
+ end
+
+ it "should set the top-level os attribute" do
+ expect(@plugin[:os]).to eql(:aix)
+ end
+
+ it "should set the top-level os_level attribute" do
+ expect(@plugin[:os_version]).to eql("7200-00-01-1543")
+ end
+ end
+
+ describe "on FreeBSD" do
+ before(:each) do
+ @plugin = get_plugin("os")
+ allow(@plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ end
+
+ it "should set os_version to __FreeBSD_version" do
+ @plugin.run
+ expect(@plugin[:os_version]).to eq("902001")
+ end
+ end
+
describe "on something we have never seen before, but ruby has" do
before do
::RbConfig::CONFIG["host_os"] = "tron"