diff options
author | Tim Smith <tsmith@chef.io> | 2018-12-02 10:39:54 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-12-05 09:57:31 -0800 |
commit | 3fe73d5eaf251ec1140949beab4e3e661c7eb287 (patch) | |
tree | 394f320e93b79ca4ad4bac311120a2169c771dda | |
parent | 8df3816b39d8ae8f2b66358eb65aa5ec2812f5f7 (diff) | |
download | ohai-3fe73d5eaf251ec1140949beab4e3e661c7eb287.tar.gz |
Fix the Windows specs
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | spec/unit/plugins/windows/cpu_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/plugins/windows/virtualization_spec.rb | 34 |
2 files changed, 18 insertions, 17 deletions
diff --git a/spec/unit/plugins/windows/cpu_spec.rb b/spec/unit/plugins/windows/cpu_spec.rb index 451af6d3..c0a17bd7 100644 --- a/spec/unit/plugins/windows/cpu_spec.rb +++ b/spec/unit/plugins/windows/cpu_spec.rb @@ -65,7 +65,6 @@ describe Ohai::System, "Windows cpu plugin" do @plugin = get_plugin("cpu") allow(@plugin).to receive(:collect_os).and_return(:windows) - @double_wmi = double(WmiLite::Wmi) @double_wmi_instance = instance_double(WmiLite::Wmi) @processors = [{ "description" => "Intel64 Family 6 Model 70 Stepping 1", diff --git a/spec/unit/plugins/windows/virtualization_spec.rb b/spec/unit/plugins/windows/virtualization_spec.rb index bde7523b..72c09e6b 100644 --- a/spec/unit/plugins/windows/virtualization_spec.rb +++ b/spec/unit/plugins/windows/virtualization_spec.rb @@ -22,21 +22,23 @@ require_relative "../../../spec_helper.rb" describe Ohai::System, "Windows virtualization platform" do let(:plugin) { get_plugin("windows/virtualization") } + let(:wmi) { double("WmiLite::Wmi") } before(:each) do + allow(WmiLite::Wmi).to receive(:new).and_return(wmi) allow(plugin).to receive(:collect_os).and_return(:windows) end describe "it sets virtualization guest status from Win32_ComputerSystemProduct data" do it "system is vmware" do - allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_ComputerSystemProduct").and_return( { "caption" => "Computer System Product", - "description" => "Computer System Product", - "identifyingnumber" => "ec2d6aad-f59b-a10d-5784-ca9b7ba4f727", - "name" => "HVM domU", - "skunumber" => nil, - "uuid" => "EC2D6AAD-F59B-A10D-5784-CA9B7BA4F727", - "vendor" => "Xen", - "version" => "4.2.amazon" } ) + allow(wmi).to receive(:first_of).with("Win32_ComputerSystemProduct").and_return( { "caption" => "Computer System Product", + "description" => "Computer System Product", + "identifyingnumber" => "ec2d6aad-f59b-a10d-5784-ca9b7ba4f727", + "name" => "HVM domU", + "skunumber" => nil, + "uuid" => "EC2D6AAD-F59B-A10D-5784-CA9B7BA4F727", + "vendor" => "Xen", + "version" => "4.2.amazon" } ) plugin.run expect(plugin[:virtualization][:system]).to eq("xen") expect(plugin[:virtualization][:role]).to eq("guest") @@ -46,14 +48,14 @@ describe Ohai::System, "Windows virtualization platform" do context "when running on a hardware system" do it "does not set virtualization attributes" do - allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_ComputerSystemProduct").and_return({ "caption" => "Computer System Product", - "description" => "Computer System Product", - "identifyingnumber" => "0123456789", - "name" => "X10SLH-N6-ST031", - "skunumber" => nil, - "uuid" => "00000000-0000-0000-0000-0CC47A8F7618", - "vendor" => "Supermicro", - "version" => "0123456789" }) + allow(wmi).to receive(:first_of).with("Win32_ComputerSystemProduct").and_return({ "caption" => "Computer System Product", + "description" => "Computer System Product", + "identifyingnumber" => "0123456789", + "name" => "X10SLH-N6-ST031", + "skunumber" => nil, + "uuid" => "00000000-0000-0000-0000-0CC47A8F7618", + "vendor" => "Supermicro", + "version" => "0123456789" }) plugin.run expect(plugin[:virtualization]).to eq("systems" => {}) end |