spec/unit/plugins/dmi_spec.rb in ohai-13.12.6 vs spec/unit/plugins/dmi_spec.rb in ohai-14.0.28

- old
+ new

@@ -99,20 +99,19 @@ Number Of Power Cords: Unspecified Contained Elements: 0 EOS describe Ohai::System, "plugin dmi" do - let(:plugin) { get_plugin("dmi") } - let(:stdout) { DMI_OUT } - before(:each) do - allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, "")) + @plugin = get_plugin("dmi") + @stdout = DMI_OUT + allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, "")) end - it "runs dmidecode" do - expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, "")) - plugin.run + it "should run dmidecode" do + expect(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, "")) + @plugin.run end # Test some simple sample data { :bios => { @@ -127,30 +126,23 @@ :lock => "Not Present", :asset_tag => "No Asset Tag", }, }.each do |id, data| data.each do |attribute, value| - it "attribute [:dmi][:#{id}][:#{attribute}] is set" do - plugin.run - expect(plugin[:dmi][id][attribute]).to eql(value) + it "should have [:dmi][:#{id}][:#{attribute}] set" do + @plugin.run + expect(@plugin[:dmi][id][attribute]).to eql(value) end - it "attribute [:dmi][:#{id}][:#{attribute}] set for windows output" do - stdout = convert_windows_output(DMI_OUT) - expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, "")) - plugin.run - expect(plugin[:dmi][id][attribute]).to eql(value) + it "should have [:dmi][:#{id}][:#{attribute}] set for windows output" do + @stdout = convert_windows_output(DMI_OUT) + expect(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, "")) + @plugin.run + expect(@plugin[:dmi][id][attribute]).to eql(value) end end end - it "allows capturing additional DMI data" do - Ohai.config[:additional_dmi_ids] = [ 16 ] - plugin.run - expect(plugin[:dmi]).to have_key(:physical_memory_array) - end - - it "correctly ignores data in excluded DMI IDs" do - expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, "")) - plugin.run - expect(plugin[:dmi]).not_to have_key(:physical_memory_array) + it "should correctly ignore unwanted data" do + @plugin.run + expect(@plugin[:dmi][:base_board]).not_to have_key(:error_correction_type) end end