diff options
Diffstat (limited to 'spec/unit/plugins')
62 files changed, 425 insertions, 232 deletions
diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb index c6334c86..58d26cb1 100644 --- a/spec/unit/plugins/azure_spec.rb +++ b/spec/unit/plugins/azure_spec.rb @@ -22,9 +22,9 @@ require 'open-uri' describe Ohai::System, "plugin azure" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("azure.rb", PLUGIN_PATH), "azure") - @plugin = @ohai.plugins[:azure][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("azure.rb", PLUGIN_PATH)).new(ohai) end describe "with azure cloud file" do diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb index 17df6cfe..461185fd 100644 --- a/spec/unit/plugins/c_spec.rb +++ b/spec/unit/plugins/c_spec.rb @@ -103,10 +103,9 @@ EOF describe Ohai::System, "plugin c" do before(:each) do - @ohai = Ohai::System.new - @path = File.join(PLUGIN_PATH, "c.rb") - Ohai::Loader.new(@ohai).load_plugin(@path, "c") - @plugin = @ohai.plugins["c"][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "c.rb")).new(ohai) @plugin[:languages] = Mash.new #gcc diff --git a/spec/unit/plugins/chef_spec.rb b/spec/unit/plugins/chef_spec.rb index 79afe3d4..48e00a93 100644 --- a/spec/unit/plugins/chef_spec.rb +++ b/spec/unit/plugins/chef_spec.rb @@ -25,9 +25,9 @@ begin describe Ohai::System, "plugin chef" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "chef.rb"), "chef") - @plugin = @ohai.plugins[:chef][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "chef.rb")).new(ohai) end it "should set [:chef_packages][:chef][:version] to the current chef version", :if => defined?(Chef) do diff --git a/spec/unit/plugins/cloud_spec.rb b/spec/unit/plugins/cloud_spec.rb index 1068e04b..7ceadd11 100644 --- a/spec/unit/plugins/cloud_spec.rb +++ b/spec/unit/plugins/cloud_spec.rb @@ -19,9 +19,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin cloud" do before do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("cloud.rb", PLUGIN_PATH), "cloud") - @plugin = @ohai.plugins[:cloud][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("cloud.rb", PLUGIN_PATH)).new(ohai) end describe "with no cloud mashes" do diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb index a9fffc40..13bbf239 100644 --- a/spec/unit/plugins/darwin/cpu_spec.rb +++ b/spec/unit/plugins/darwin/cpu_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin cpu plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("darwin/cpu.rb", PLUGIN_PATH), "dcpu") - @plugin = @ohai.plugins[:dcpu][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("darwin/cpu.rb", PLUGIN_PATH)).new(ohai) @plugin.stub(:from).with("sysctl -n hw.physicalcpu").and_return("1") @plugin.stub(:from).with("sysctl -n hw.logicalcpu").and_return("2") diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb index c0ba6834..bd18592d 100644 --- a/spec/unit/plugins/darwin/hostname_spec.rb +++ b/spec/unit/plugins/darwin/hostname_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin hostname plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("darwin/hostname.rb", PLUGIN_PATH), "dhost") - @plugin = @ohai.plugins[:dhost][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("darwin/hostname.rb", PLUGIN_PATH)).new(ohai) @plugin[:os] = "darwin" @plugin.stub(:from).with("hostname -s").and_return("katie") @plugin.stub(:from).with("hostname").and_return("katie.bethell") diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb index 932bec4b..d22d5602 100644 --- a/spec/unit/plugins/darwin/kernel_spec.rb +++ b/spec/unit/plugins/darwin/kernel_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin kernel plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("darwin/kernel.rb", PLUGIN_PATH), "dkern") - @plugin = @ohai.plugins[:dkern][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("darwin/kernel.rb", PLUGIN_PATH)).new(ohai) @plugin[:kernel] = Mash.new @plugin[:kernel][:name] = "darwin" @plugin.should_receive(:popen4).with("kextstat -k -l").and_yield(1, StringIO.new, StringIO.new, StringIO.new) diff --git a/spec/unit/plugins/darwin/network_spec.rb b/spec/unit/plugins/darwin/network_spec.rb index cd1adbdd..fe44bfe7 100644 --- a/spec/unit/plugins/darwin/network_spec.rb +++ b/spec/unit/plugins/darwin/network_spec.rb @@ -412,10 +412,9 @@ net.smb.fs.tcpsndbuf: 261120 net.smb.fs.tcprcvbuf: 261120 DARWIN_SYSCTL - @ohai = Ohai::System.new - @loader = Ohai::Loader.new(@ohai) - @loader.load_plugin(File.expand_path("darwin/network.rb", PLUGIN_PATH), "dnet") - @plugin = @ohai.plugins[:dnet][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("darwin/network.rb", PLUGIN_PATH)).new(ohai) @stdin_ifconfig = StringIO.new @stdin_arp = StringIO.new @@ -433,9 +432,7 @@ net.smb.fs.tcprcvbuf: 261120 Ohai::Log.should_receive(:warn).with(/unable to detect/).exactly(3).times %w{ darwin/hostname hostname network }.each do |plgn| - key = plgn.gsub("/", "_") - @loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH), key) - p = @ohai.plugins[key][:plugin].new(@ohai) + p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)).new(ohai) p.stub(:from).with("hostname -s").and_return("katie") p.stub(:from).with("hostname").and_return("katie.bethell") p.run diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb index 87814553..068dc266 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin plugin platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("darwin/platform.rb", PLUGIN_PATH), "dplat") - @plugin = @ohai.plugins[:dplat][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("darwin/platform.rb", PLUGIN_PATH)).new(ohai) @plugin[:os] = "darwin" @pid = 10 @stdin = double("STDIN", { :close => true }) diff --git a/spec/unit/plugins/darwin/system_profiler_spec.rb b/spec/unit/plugins/darwin/system_profiler_spec.rb index 672a8453..d13505b0 100644 --- a/spec/unit/plugins/darwin/system_profiler_spec.rb +++ b/spec/unit/plugins/darwin/system_profiler_spec.rb @@ -28,9 +28,9 @@ end describe Ohai::System, "Darwin system_profiler plugin", :unix_only do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("darwin/system_profiler.rb", PLUGIN_PATH), "dpro") - @plugin = @ohai.plugins[:dpro][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("darwin/system_profiler.rb", PLUGIN_PATH)).new(ohai) end it "should return the right serial number" do diff --git a/spec/unit/plugins/dmi_spec.rb b/spec/unit/plugins/dmi_spec.rb index bebb345d..f5ed3bdc 100644 --- a/spec/unit/plugins/dmi_spec.rb +++ b/spec/unit/plugins/dmi_spec.rb @@ -93,9 +93,9 @@ EOS describe Ohai::System, "plugin dmi" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("dmi.rb", PLUGIN_PATH), "dmi") - @plugin = @ohai.plugins[:dmi][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("dmi.rb", PLUGIN_PATH)).new(ohai) @stdin = double("STDIN", { :close => true }) @pid = 10 @stderr = double("STDERR") diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb index 7cecf5d7..4da89d38 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -22,9 +22,9 @@ require 'open-uri' describe Ohai::System, "plugin ec2" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "ec2.rb"), "ec2") - @plugin = @ohai.plugins[:ec2][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ec2.rb")).new(ohai) @plugin[:network] = {:interfaces => {:eth0 => {} } } end diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb index 8bf6d013..3f821ba7 100644 --- a/spec/unit/plugins/erlang_spec.rb +++ b/spec/unit/plugins/erlang_spec.rb @@ -24,9 +24,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'path', 'ohai_p describe Ohai::System, "plugin erlang" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("erlang.rb", PLUGIN_PATH), "erl") - @plugin = @ohai.plugins[:erl][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("erlang.rb", PLUGIN_PATH)).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdin = "" diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb index f32b553e..917dc69a 100644 --- a/spec/unit/plugins/eucalyptus_spec.rb +++ b/spec/unit/plugins/eucalyptus_spec.rb @@ -22,9 +22,9 @@ require 'open-uri' describe Ohai::System, "plugin eucalyptus" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "eucalyptus.rb"), "euca") - @plugin = @ohai.plugins[:euca][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "eucalyptus.rb")).new(ohai) end shared_examples_for "!eucalyptus" do diff --git a/spec/unit/plugins/fail_spec.rb b/spec/unit/plugins/fail_spec.rb index 24ac4070..1f3fa941 100644 --- a/spec/unit/plugins/fail_spec.rb +++ b/spec/unit/plugins/fail_spec.rb @@ -1,6 +1,7 @@ # # Author:: Toomas Pelberg (toomas.pelberg@playtech.com>) -# Copyright:: Copyright (c) 2011 Opscode, Inc. +# Author:: Claire McQuin (claire@opscode.com) +# Copyright:: Copyright (c) 2011, 2013 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,49 +21,253 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he tmp = ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] || '/tmp' -describe Ohai::System, "plugin fail" do - +shared_examples "a v7 loading failure" do before(:all) do begin Dir.mkdir("#{tmp}/plugins") rescue Errno::EEXIST - # Ignore it + # ignore end - fail_plugin=File.open("#{tmp}/plugins/fail.rb","w+") - fail_plugin.write("provides \"fail\"require 'thiswillblowupinyourface'\nk=MissingClassName.new\nfail \"ohnoes\"") - fail_plugin.close - real_plugin=File.open("#{tmp}/plugins/real.rb","w+") - real_plugin.write("Ohai.plugin do\nprovides \"real\"\ncollect_data do\nreal \"useful\"\nend\nend\n") - real_plugin.close - @plugin_path=Ohai::Config[:plugin_path] end - + before(:each) do - Ohai::Config[:plugin_path]=["#{tmp}/plugins"] - @ohai=Ohai::System.new - @loader=Ohai::Loader.new(@ohai) + fail_file = File.open("#{tmp}/plugins/fail.rb", "w+") + fail_file.write(failstr) + fail_file.close end - + + after(:each) do + File.delete("#{tmp}/plugins/fail.rb") + end + after(:all) do + begin + Dir.delete("#{tmp}/plugins") + rescue + # ignore + end + end + + before(:each) do + @ohai = Ohai::System.new + @loader = Ohai::Loader.new(@ohai) + end + + it "should not have attribute keys" do + @loader.load_plugin("#{tmp}/plugins/fail.rb") + @ohai.attributes.should_not have_key("fail") + end + + it "should not have source key" do + @loader.load_plugin("#{tmp}/plugins/fail.rb") + @ohai.v6_dependency_solver.should_not have_key("#{tmp}/plugins/fail.rb") + end + + it "should write to Ohai::Log" do + Ohai::Log.should_receive(:debug).twice + @loader.load_plugin("#{tmp}/plugins/fail.rb") + end +end + +shared_examples "a v7 loading success" do + before(:all) do + begin + Dir.mkdir("#{tmp}/plugins") + rescue Errno::EEXIST + # ignore + end + end + + before(:each) do + fail_file = File.open("#{tmp}/plugins/fail.rb", "w+") + fail_file.write(failstr) + fail_file.close + end + + after(:each) do File.delete("#{tmp}/plugins/fail.rb") - File.delete("#{tmp}/plugins/real.rb") + end + + after(:all) do begin Dir.delete("#{tmp}/plugins") rescue - # Don't care if it fails + # ignore end - Ohai::Config[:plugin_path]=@plugin_path end - - it "should continue gracefully if plugin loading fails" do + + before(:each) do + @ohai = Ohai::System.new + @loader = Ohai::Loader.new(@ohai) + end + + it "should have attribute keys" do + @loader.load_plugin("#{tmp}/plugins/fail.rb") + @ohai.attributes.should have_key("fail") + end + + it "should have source key" do @loader.load_plugin("#{tmp}/plugins/fail.rb") - @loader.load_plugin("#{tmp}/plugins/real.rb") + @ohai.v6_dependency_solver.should have_key("#{tmp}/plugins/fail.rb") + end + + it "should not write to Ohai::Log" do + Ohai::Log.should_not_receive(:debug) + @loader.load_plugin("#{tmp}/plugins/fail.rb") + end +end + +shared_examples "a v7 run failure" do + before(:all) do + begin + Dir.mkdir("#{tmp}/plugins") + rescue Errno::EEXIST + # ignore + end + end + + before(:each) do + fail_file = File.open("#{tmp}/plugins/fail.rb", "w+") + fail_file.write(failstr) + fail_file.close + end + + after(:each) do + File.delete("#{tmp}/plugins/fail.rb") + end + + after(:all) do + begin + Dir.delete("#{tmp}/plugins") + rescue + # ignore + end + end + + before(:each) do + @ohai = Ohai::System.new + @loader = Ohai::Loader.new(@ohai) + end + + it "should not have new attribute keys" do + @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run + @ohai.attributes.should_not have_key("other") + end - @ohai.plugins.keys.each do |plgn_key| - @ohai.plugins[plgn_key][:plugin].new(@ohai).run + it "should write to Ohai::Log" do + Ohai::Log.should_receive(:debug).once + @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run + end +end + +shared_examples "a v6 run failure" do + before(:all) do + begin + Dir.mkdir("#{tmp}/plugins") + rescue Errno::EEXIST + # ignore end - - @ohai.data[:real].should eql("useful") + end + + before(:each) do + fail_file = File.open("#{tmp}/plugins/fail.rb", "w+") + fail_file.write(failstr) + fail_file.close + end + + after(:each) do + File.delete("#{tmp}/plugins/fail.rb") + end + + after(:all) do + begin + Dir.delete("#{tmp}/plugins") + rescue + # ignore + end + end + + before(:each) do + @ohai = Ohai::System.new + @loader = Ohai::Loader.new(@ohai) + end + + it "should not add data keys" do + @loader.load_plugin("#{tmp}/plugins/fail.rb") @ohai.data.should_not have_key("fail") end + + it "should write to Ohai::Log" do + Ohai::Log.should_receive(:debug).twice + @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run + end +end + +describe "when using DSL commands outside Ohai.plugin block" do + failstr1 = "provides \"fail\"\nOhai.plugin do\nend\n" + failstr2 = "depends \"fail\"\nOhai.plugin do\nend\n" + failstr3 = "collect_data do\nend\nOhai.plugin do\nend\n" + + it_behaves_like "a v7 loading failure" do + let(:failstr) { failstr1 } + end + + it_behaves_like "a v7 loading failure" do + let(:failstr) { failstr2 } + end + + it_behaves_like "a v7 loading failure" do + let(:failstr) { failstr3 } + end +end + +describe "when using nonexistent DSL commands in Ohai.plugin block" do + failstr = "Ohai.plugin do\n\tcreates \"fail\"\nend\n" + + it_behaves_like "a v7 loading failure" do + let(:failstr) { failstr } + end +end + +=begin +describe "when using DSL commands in collect_data block" do + failstr1 = "Ohai.plugin do\n\tprovides \"fail\"\n\tcollect_data do\n\t\tprovides \"other\"\n\tend\nend\n" + failstr2 = "Ohai.plugin do\n\tprovides \"fail\"\n\tcollect_data do\n\t\tdepends \"other\"\n\tend\nend\n" + + it_behaves_like "a v7 loading success" do + let(:failstr) { failstr1 } + end + + it_behaves_like "a v7 run failure" do + let(:failstr) { failstr1 } + end + + it_behaves_like "a v7 loading success" do + let(:failstr) { failstr2 } + end + + it_behaves_like "a v7 run failure" do + let(:failstr) { failstr2 } + end +end + +describe "when setting undeclared attribute in collect_data block" do + failstr = "Ohai.plugin do\n\tprovides \"fail\"\n\tcollect_data do\n\t\tcreates \"other\"\n\tend\nend\n" + + it_behaves_like "a v7 loading success" do + let(:failstr) { failstr } + end + + it_behaves_like "a v7 run failure" do + let(:failstr) { failstr } + end +end + +describe "when setting undeclared attribute" do + failstr = "provides \"fail\"\nother \"attribute\"\n" + + it_behaves_like "a v6 run failure" do + let(:failstr) { failstr } + end end +=end diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb index 900f94d8..81555e6e 100644 --- a/spec/unit/plugins/freebsd/hostname_spec.rb +++ b/spec/unit/plugins/freebsd/hostname_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD hostname plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("freebsd/hostname.rb", PLUGIN_PATH), "fhost") - @plugin = @ohai.plugins[:fhost][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("freebsd/hostname.rb", PLUGIN_PATH)).new(ohai) @plugin[:os] = "freebsd" @plugin.stub(:from).with("hostname -s").and_return("katie") @plugin.stub(:from).with("hostname -f").and_return("katie.bethell") diff --git a/spec/unit/plugins/freebsd/kernel_spec.rb b/spec/unit/plugins/freebsd/kernel_spec.rb index 68290bfc..52d0d370 100644 --- a/spec/unit/plugins/freebsd/kernel_spec.rb +++ b/spec/unit/plugins/freebsd/kernel_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD kernel plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("freebsd/kernel.rb", PLUGIN_PATH), "fkern") - @plugin = @ohai.plugins[:fkern][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("freebsd/kernel.rb", PLUGIN_PATH)).new(ohai) @plugin.stub(:from).with("uname -i").and_return("foo") @plugin.stub(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel: (.+)$/).and_return("kern.securelevel: 1") @plugin.stub(:popen4).with("/sbin/kldstat").and_yield(0, StringIO.new, StringIO.new, StringIO.new) diff --git a/spec/unit/plugins/freebsd/platform_spec.rb b/spec/unit/plugins/freebsd/platform_spec.rb index 35cda6d7..ce686248 100644 --- a/spec/unit/plugins/freebsd/platform_spec.rb +++ b/spec/unit/plugins/freebsd/platform_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD plugin platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("freebsd/platform.rb", PLUGIN_PATH), "fplat") - @plugin = @ohai.plugins[:fplat][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("freebsd/platform.rb", PLUGIN_PATH)).new(ohai) @plugin.stub(:from).with("uname -s").and_return("FreeBSD") @plugin.stub(:from).with("uname -r").and_return("7.1") @plugin[:os] = "freebsd" diff --git a/spec/unit/plugins/freebsd/virtualization_spec.rb b/spec/unit/plugins/freebsd/virtualization_spec.rb index d6f8e4cb..fdcda147 100644 --- a/spec/unit/plugins/freebsd/virtualization_spec.rb +++ b/spec/unit/plugins/freebsd/virtualization_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD virtualization plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("freebsd/virtualization.rb", PLUGIN_PATH), "fvirt") - @plugin = @ohai.plugins[:fvirt][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("freebsd/virtualization.rb", PLUGIN_PATH)).new(ohai) @plugin[:os] = "freebsd" @stderr = StringIO.new @stdin = StringIO.new diff --git a/spec/unit/plugins/gce_spec.rb b/spec/unit/plugins/gce_spec.rb index 92b00634..5add3839 100644 --- a/spec/unit/plugins/gce_spec.rb +++ b/spec/unit/plugins/gce_spec.rb @@ -20,9 +20,9 @@ require 'open-uri' describe Ohai::System, "plugin gce" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.expand_path("gce.rb", PLUGIN_PATH), "gce") - @plugin = @ohai.plugins[:gce][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("gce.rb", PLUGIN_PATH)).new(ohai) end shared_examples_for "!gce" do diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb index 1f33e5d2..14222c8a 100644 --- a/spec/unit/plugins/groovy_spec.rb +++ b/spec/unit/plugins/groovy_spec.rb @@ -22,9 +22,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin groovy" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "groovy.rb"), "groovy") - @plugin = @ohai.plugins[:groovy][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "groovy.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "Groovy Version: 1.6.3 JVM: 1.6.0_0\n" diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb index 55eb623d..cec415ea 100644 --- a/spec/unit/plugins/hostname_spec.rb +++ b/spec/unit/plugins/hostname_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "hostname plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "hostname.rb"), "hostname") - @plugin = @ohai.plugins[:hostname][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "hostname.rb")).new(ohai) end it "should set the domain to everything after the first dot of the fqdn" do diff --git a/spec/unit/plugins/java_spec.rb b/spec/unit/plugins/java_spec.rb index 36576439..ee2dbd38 100644 --- a/spec/unit/plugins/java_spec.rb +++ b/spec/unit/plugins/java_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin java (Java5 Client VM)" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "java.rb"), "java") - @plugin = @ohai.plugins[:java][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "java.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "" @@ -73,9 +73,9 @@ end describe Ohai::System, "plugin java (Java6 Server VM)" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "java.rb"), "java") - @plugin = @ohai.plugins[:java][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "java.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "" diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb index afbee346..afa46a3f 100644 --- a/spec/unit/plugins/kernel_spec.rb +++ b/spec/unit/plugins/kernel_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin kernel" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "kernel.rb"), "kern") - @plugin = @ohai.plugins[:kern][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "kernel.rb")).new(ohai) @plugin[:languages] = Mash.new @plugin[:languages][:ruby] = Mash.new diff --git a/spec/unit/plugins/linode_spec.rb b/spec/unit/plugins/linode_spec.rb index 299030e9..dcd09723 100644 --- a/spec/unit/plugins/linode_spec.rb +++ b/spec/unit/plugins/linode_spec.rb @@ -22,9 +22,9 @@ describe Ohai::System, "plugin linode" do let(:hint_path_win) { 'C:\chef\ohai\hints/linode.json' } before do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linode.rb"), "lin") - @plugin = @ohai.plugins[:lin][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linode.rb")).new(ohai) @plugin[:network] = { "interfaces"=> { "eth0"=> { diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index b9bf2319..a5720c7e 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux cpu plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/cpu.rb"), "lcpu") - @plugin = @ohai.plugins[:lcpu][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/cpu.rb")).new(ohai) @plugin[:os] = "linux" @double_file = double("/proc/cpuinfo") @double_file.stub(:each). diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb index eb8e4480..171109d0 100644 --- a/spec/unit/plugins/linux/filesystem_spec.rb +++ b/spec/unit/plugins/linux/filesystem_spec.rb @@ -20,9 +20,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux filesystem plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/filesystem.rb"), "lfs") - @plugin = @ohai.plugins[:lfs][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/filesystem.rb")).new(ohai) @plugin[:os] = "linux" @plugin.extend(SimpleFromFile) diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb index 60a76034..416e3c36 100644 --- a/spec/unit/plugins/linux/hostname_spec.rb +++ b/spec/unit/plugins/linux/hostname_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux hostname plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/hostname.rb"), "lhost") - @plugin = @ohai.plugins[:lhost][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/hostname.rb")).new(ohai) @plugin[:os] = "linux" @plugin.stub(:from).with("hostname -s").and_return("katie") @plugin.stub(:from).with("hostname --fqdn").and_return("katie.bethell") diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb index 60e6de32..ae42ac51 100644 --- a/spec/unit/plugins/linux/kernel_spec.rb +++ b/spec/unit/plugins/linux/kernel_spec.rb @@ -23,9 +23,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../path/ohai_plugin_commo describe Ohai::System, "Linux kernel plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/kernel.rb"), "lkern") - @plugin = @ohai.plugins[:lkern][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/kernel.rb")).new(ohai) @plugin.stub(:from).with("uname -o").and_return("Linux") @plugin.should_receive(:popen4).with("env lsmod").at_least(1).times @plugin[:kernel] = {} diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb index 991114af..b5229e9e 100644 --- a/spec/unit/plugins/linux/lsb_spec.rb +++ b/spec/unit/plugins/linux/lsb_spec.rb @@ -23,9 +23,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux lsb plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/lsb.rb"), "lsb") - @plugin = @ohai.plugins[:lsb][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/lsb.rb")).new(ohai) @plugin[:os] = "linux" @plugin.extend(SimpleFromFile) end diff --git a/spec/unit/plugins/linux/network_spec.rb b/spec/unit/plugins/linux/network_spec.rb index 450bf98a..fbb80542 100644 --- a/spec/unit/plugins/linux/network_spec.rb +++ b/spec/unit/plugins/linux/network_spec.rb @@ -277,19 +277,15 @@ IP_ROUTE_SCOPE prepare_data - @ohai = Ohai::System.new - @loader = Ohai::Loader.new(@ohai) - @loader.load_plugin(File.join(PLUGIN_PATH, "linux/network.rb"), "lnet") - @plugin = @ohai.plugins[:lnet][:plugin].new(@ohai) - + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/network.rb")).new(ohai) @plugin.stub(:popen4).with("ifconfig -a") @plugin.stub(:popen4).with("arp -an") Ohai::Log.should_receive(:warn).with(/unable to detect/).exactly(3).times %w{ linux/hostname hostname network }.each do |plgn| - key = plgn.gsub("/", "_") - @loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH), key) - p = @ohai.plugins[key][:plugin].new(@ohai) + p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)).new(ohai) p.stub(:from).with("hostname -s").and_return("katie") p.stub(:from).with("hostname --fqdn").and_return("katie.bethell") p.run diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 9b5397f7..e293f532 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -22,9 +22,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux plugin platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/platform.rb"), "lplat") - @plugin = @ohai.plugins[:lplat][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/platform.rb")).new(ohai) @plugin.extend(SimpleFromFile) @plugin[:os] = "linux" @plugin[:lsb] = Mash.new diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb index a636a5b5..9af200d7 100644 --- a/spec/unit/plugins/linux/uptime_spec.rb +++ b/spec/unit/plugins/linux/uptime_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux plugin uptime" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/uptime.rb"), "lup") - @plugin = @ohai.plugins[:lup][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/uptime.rb")).new(ohai) @plugin[:os] = "linux" @double_file = double("/proc/uptime", { :gets => "18423 989" }) File.stub(:open).with("/proc/uptime").and_return(@double_file) diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb index 4f5abeac..58f48925 100644 --- a/spec/unit/plugins/linux/virtualization_spec.rb +++ b/spec/unit/plugins/linux/virtualization_spec.rb @@ -20,9 +20,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux virtualization platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "linux/virtualization.rb"), "lvirt") - @plugin = @ohai.plugins[:lvirt][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/virtualization.rb")).new(ohai) @plugin[:os] = "linux" @plugin.extend(SimpleFromFile) diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb index 4234a993..06d3c0f3 100644 --- a/spec/unit/plugins/lua_spec.rb +++ b/spec/unit/plugins/lua_spec.rb @@ -24,9 +24,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin lua" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "lua.rb"), "lua") - @plugin = @ohai.plugins[:lua][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "lua.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "" diff --git a/spec/unit/plugins/mono_spec.rb b/spec/unit/plugins/mono_spec.rb index 0fa06304..53cc19d3 100644 --- a/spec/unit/plugins/mono_spec.rb +++ b/spec/unit/plugins/mono_spec.rb @@ -22,9 +22,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin mono" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "mono.rb"), "mono") - @plugin = @ohai.plugins[:mono][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "mono.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n" diff --git a/spec/unit/plugins/netbsd/hostname_spec.rb b/spec/unit/plugins/netbsd/hostname_spec.rb index 18eb1db1..16267d89 100644 --- a/spec/unit/plugins/netbsd/hostname_spec.rb +++ b/spec/unit/plugins/netbsd/hostname_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "NetBSD hostname plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "netbsd/hostname.rb"), "nhost") - @plugin = @ohai.plugins[:nhost][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "netbsd/hostname.rb")).new(ohai) @plugin[:os] = "netbsd" @plugin.stub(:from).with("hostname -s").and_return("katie") @plugin.stub(:from).with("hostname").and_return("katie.bethell") diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb index 75c634bc..8ef1af95 100644 --- a/spec/unit/plugins/netbsd/kernel_spec.rb +++ b/spec/unit/plugins/netbsd/kernel_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "NetBSD kernel plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "netbsd/kernel.rb"), "nkern") - @plugin = @ohai.plugins[:nkern][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "netbsd/kernel.rb")).new(ohai) @plugin.stub(:from).with("uname -i").and_return("foo") @plugin.stub(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel=(.+)$/).and_return("kern.securelevel: 1") @plugin.should_receive(:popen4).with("/usr/bin/modstat").and_yield(1, StringIO.new, StringIO.new, StringIO.new) diff --git a/spec/unit/plugins/netbsd/platform_spec.rb b/spec/unit/plugins/netbsd/platform_spec.rb index bd848e35..458588ce 100644 --- a/spec/unit/plugins/netbsd/platform_spec.rb +++ b/spec/unit/plugins/netbsd/platform_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "NetBSD plugin platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "netbsd/platform.rb"), "nplat") - @plugin = @ohai.plugins[:nplat][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "netbsd/platform.rb")).new(ohai) @plugin.stub(:from).with("uname -s").and_return("NetBSD") @plugin.stub(:from).with("uname -r").and_return("4.5") @plugin[:os] = "netbsd" diff --git a/spec/unit/plugins/network_spec.rb b/spec/unit/plugins/network_spec.rb index fd346a23..3bdc8f2f 100644 --- a/spec/unit/plugins/network_spec.rb +++ b/spec/unit/plugins/network_spec.rb @@ -23,7 +23,7 @@ def it_does_not_fail Ohai::Log.stub(:warn) Ohai::Log.should_not_receive(:debug).with(/^Plugin network threw exception/) @plugin.run - %w[ ipaddress, macaddress, ip6address ].each do |attribute| + %w{ ipaddress macaddress ip6address }.each do |attribute| @plugin.should have_key(attribute) end end @@ -149,9 +149,9 @@ describe Ohai::System, "Network Plugin" do describe "with linux" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "network.rb"), "net") - @plugin = @ohai.plugins[:net][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "network.rb")).new(ohai) @plugin["network"] = basic_data["linux"]["network"] end diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb index 9284b7fd..4a3302b9 100644 --- a/spec/unit/plugins/nodejs_spec.rb +++ b/spec/unit/plugins/nodejs_spec.rb @@ -23,9 +23,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin nodejs" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "nodejs.rb"), "njs") - @plugin = @ohai.plugins[:njs][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "nodejs.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "v0.8.11\n" diff --git a/spec/unit/plugins/ohai_spec.rb b/spec/unit/plugins/ohai_spec.rb index ffa84007..d4f1087e 100644 --- a/spec/unit/plugins/ohai_spec.rb +++ b/spec/unit/plugins/ohai_spec.rb @@ -22,9 +22,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin ohai" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "ohai.rb"), "ohai") - @plugin = @ohai.plugins[:ohai][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ohai.rb")).new(ohai) end it "should set [:chef_packages][:ohai][:version] to the current version" do diff --git a/spec/unit/plugins/ohai_time_spec.rb b/spec/unit/plugins/ohai_time_spec.rb index d47f3a24..59eaab51 100644 --- a/spec/unit/plugins/ohai_time_spec.rb +++ b/spec/unit/plugins/ohai_time_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin ohai_time" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "ohai_time.rb"), "otime") - @plugin = @ohai.plugins[:otime][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ohai_time.rb")).new(ohai) end it "should get the current time" do diff --git a/spec/unit/plugins/openbsd/hostname_spec.rb b/spec/unit/plugins/openbsd/hostname_spec.rb index 670e743d..e8e5e2ec 100644 --- a/spec/unit/plugins/openbsd/hostname_spec.rb +++ b/spec/unit/plugins/openbsd/hostname_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "OpenBSD hostname plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "openbsd/hostname.rb"), "ohost") - @plugin = @ohai.plugins[:ohost][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "openbsd/hostname.rb")).new(ohai) @plugin[:os] = "openbsd" @plugin.stub(:from).with("hostname -s").and_return("katie") @plugin.stub(:from).with("hostname").and_return("katie.bethell") diff --git a/spec/unit/plugins/openbsd/kernel_spec.rb b/spec/unit/plugins/openbsd/kernel_spec.rb index 9fd960fb..2c2f50b5 100644 --- a/spec/unit/plugins/openbsd/kernel_spec.rb +++ b/spec/unit/plugins/openbsd/kernel_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "OpenBSD kernel plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "openbsd/kernel.rb"), "okern") - @plugin = @ohai.plugins[:okern][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "openbsd/kernel.rb")).new(ohai) @plugin.stub(:from).with("uname -i").and_return("foo") @plugin.stub(:from_with_regex).with("sysctl kern.securelevel", /kern.securelevel=(.+)$/).and_return("kern.securelevel: 1") @plugin.should_receive(:popen4).with("/usr/bin/modstat").and_yield(1, StringIO.new, StringIO.new, StringIO.new) diff --git a/spec/unit/plugins/openbsd/platform_spec.rb b/spec/unit/plugins/openbsd/platform_spec.rb index de9cd38a..d9138553 100644 --- a/spec/unit/plugins/openbsd/platform_spec.rb +++ b/spec/unit/plugins/openbsd/platform_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "OpenBSD plugin platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "openbsd/platform.rb"), "oplat") - @plugin = @ohai.plugins[:oplat][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "openbsd/platform.rb")).new(ohai) @plugin.stub(:from).with("uname -s").and_return("OpenBSD") @plugin.stub(:from).with("uname -r").and_return("4.5") @plugin[:os] = "openbsd" diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb index d5262e75..c776b603 100644 --- a/spec/unit/plugins/os_spec.rb +++ b/spec/unit/plugins/os_spec.rb @@ -23,9 +23,9 @@ ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG['host_os'] describe Ohai::System, "plugin os" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "os.rb"), "os") - @plugin = @ohai.plugins[:os][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "os.rb")).new(ohai) @plugin[:languages] = Mash.new @plugin[:languages][:ruby] = Mash.new @plugin[:kernel] = Mash.new diff --git a/spec/unit/plugins/passwd_spec.rb b/spec/unit/plugins/passwd_spec.rb index 4c9a2952..839ef5b4 100644 --- a/spec/unit/plugins/passwd_spec.rb +++ b/spec/unit/plugins/passwd_spec.rb @@ -2,9 +2,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin etc" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "passwd.rb"), "etc") - @plugin = @ohai.plugins[:etc][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "passwd.rb")).new(ohai) end PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos) diff --git a/spec/unit/plugins/perl_spec.rb b/spec/unit/plugins/perl_spec.rb index 847f1f08..1c66967e 100644 --- a/spec/unit/plugins/perl_spec.rb +++ b/spec/unit/plugins/perl_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin perl" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "perl.rb"), "perl") - @plugin = @ohai.plugins[:perl][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "perl.rb")).new(ohai) @plugin[:languages] = Mash.new @pid = 2342 @stderr = StringIO.new diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb index cdc5cd6e..36691dec 100644 --- a/spec/unit/plugins/php_spec.rb +++ b/spec/unit/plugins/php_spec.rb @@ -25,9 +25,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'path', 'ohai_p describe Ohai::System, "plugin php" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "php.rb"), "php") - @plugin = @ohai.plugins[:php][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "php.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n" diff --git a/spec/unit/plugins/platform_spec.rb b/spec/unit/plugins/platform_spec.rb index 1af03214..6dc20469 100644 --- a/spec/unit/plugins/platform_spec.rb +++ b/spec/unit/plugins/platform_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "platform.rb"), "plat") - @plugin = @ohai.plugins[:plat][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "platform.rb")).new(ohai) @plugin[:os] = 'monkey' @plugin[:os_version] = 'poop' end diff --git a/spec/unit/plugins/python_spec.rb b/spec/unit/plugins/python_spec.rb index b6eeb101..57c52a98 100644 --- a/spec/unit/plugins/python_spec.rb +++ b/spec/unit/plugins/python_spec.rb @@ -23,9 +23,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin python" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "python.rb"), "py") - @plugin = @ohai.plugins[:py][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "python.rb")).new(ohai) @plugin[:languages] = Mash.new @status = 0 @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index 13878c25..be87ddb9 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -19,9 +19,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin rackspace" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "rackspace.rb"), "rack") - @plugin = @ohai.plugins[:rack][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "rackspace.rb")).new(ohai) @plugin[:network] = {:interfaces => {:eth0 => {"addresses"=> { "1.2.3.4"=> { "broadcast"=> "67.23.20.255", diff --git a/spec/unit/plugins/root_group_spec.rb b/spec/unit/plugins/root_group_spec.rb index f1134e98..ee7e0fd6 100644 --- a/spec/unit/plugins/root_group_spec.rb +++ b/spec/unit/plugins/root_group_spec.rb @@ -22,9 +22,9 @@ ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG['host_os'] describe Ohai::System, 'root_group' do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "root_group.rb"), "root") - @plugin = @ohai.plugins[:root][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "root_group.rb")).new(ohai) end describe 'unix platform', :unix_only do diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb index 9a18c663..76f76850 100644 --- a/spec/unit/plugins/ruby_spec.rb +++ b/spec/unit/plugins/ruby_spec.rb @@ -24,9 +24,9 @@ ruby_bin = File.join(::RbConfig::CONFIG['bindir'], ::RbConfig::CONFIG['ruby_inst describe Ohai::System, "plugin ruby" do before(:all) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "ruby.rb"), "ruby") - @plugin = @ohai.plugins[:ruby][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ruby.rb")).new(ohai) @plugin[:languages] = Mash.new @plugin.run diff --git a/spec/unit/plugins/sigar/network_route_spec.rb b/spec/unit/plugins/sigar/network_route_spec.rb index cc0250e3..32658c33 100644 --- a/spec/unit/plugins/sigar/network_route_spec.rb +++ b/spec/unit/plugins/sigar/network_route_spec.rb @@ -32,10 +32,9 @@ describe Ohai::System, "Sigar network route plugin" do if sigar_available before(:each) do - @ohai = Ohai::System.new - @loader = Ohai::Loader.new(@ohai) - @loader.load_plugin(File.expand_path("sigar/network_route.rb", PLUGIN_PATH), "snr") - @plugin = @ohai.plugins[:snr][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.expand_path("sigar/network_route.rb", PLUGIN_PATH)).new(ohai) @sigar = double("Sigar") @net_info_conf={ :default_gateway => "192.168.1.254", @@ -125,20 +124,17 @@ describe Ohai::System, "Sigar network route plugin" do Sigar.should_receive(:new).at_least(2).times.and_return(@sigar) %w{ languages ruby kernel os }.each do |plgn| - @loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH), plgn) - @ohai.plugins[plgn][:plugin].new(@ohai).run + p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)) + p.new(ohai).run end - @ohai.data[:os]="sigar" + @plugin.data[:os]="sigar" #Ohai::Log.should_receive(:warn).with(/unable to detect ip6address/).once %w{ sigar/hostname hostname sigar/network network }.each do |plgn| - plgn_key = plgn.gsub("/", "_") - @loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH), plgn_key) - @ohai.plugins[plgn_key][:plugin].new(@ohai).run + p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)) + p.new(ohai).run end - @loader.load_plugin(File.expand_path("sigar/network_route.rb", PLUGIN_PATH), "snr") - @plugin = @ohai.plugins[:snr][:plugin].new(@ohai) @plugin.run end diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb index 54456370..0ac46bfb 100644 --- a/spec/unit/plugins/solaris2/hostname_spec.rb +++ b/spec/unit/plugins/solaris2/hostname_spec.rb @@ -20,9 +20,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Solaris2.X hostname plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "solaris2/hostname.rb"), "shost") - @plugin = @ohai.plugins[:shost][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/hostname.rb")).new(ohai) @plugin[:os] = "solaris2" @plugin.stub(:from).with("hostname").and_return("kitteh") Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] ); diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb index 62e0daed..5b0981c3 100644 --- a/spec/unit/plugins/solaris2/kernel_spec.rb +++ b/spec/unit/plugins/solaris2/kernel_spec.rb @@ -134,9 +134,9 @@ describe Ohai::System, "Solaris2.X kernel plugin" do TOOMUCH before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "solaris2/kernel.rb"), "skern") - @plugin = @ohai.plugins[:skern][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/kernel.rb")).new(ohai) @plugin[:kernel] = Mash.new @plugin.stub(:from).with("uname -s").and_return("SunOS") stdin = StringIO.new diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb index be28193f..27259c91 100644 --- a/spec/unit/plugins/solaris2/network_spec.rb +++ b/spec/unit/plugins/solaris2/network_spec.rb @@ -89,9 +89,9 @@ ROUTE_GET @ifconfig_lines = solaris_ifconfig.split("\n") - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "solaris2/network.rb"), "snet") - @plugin = @ohai.plugins[:snet][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/network.rb")).new(ohai) @plugin[:network] = Mash.new @plugin.stub(:popen4).with("ifconfig -a") diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb index 771cc125..306b53ef 100644 --- a/spec/unit/plugins/solaris2/platform_spec.rb +++ b/spec/unit/plugins/solaris2/platform_spec.rb @@ -20,9 +20,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Solaris plugin platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "solaris2/platform.rb"), "splat") - @plugin = @ohai.plugins[:splat][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/platform.rb")).new(ohai) @plugin.extend(SimpleFromFile) @plugin[:os] = "solaris2" @plugin.stub(:popen4).with("/sbin/uname -X") diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb index 02c33acd..2acc8b5d 100644 --- a/spec/unit/plugins/solaris2/virtualization_spec.rb +++ b/spec/unit/plugins/solaris2/virtualization_spec.rb @@ -20,9 +20,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Solaris virtualization platform" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "solaris2/virtualization.rb"), "svirt") - @plugin = @ohai.plugins[:svirt][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/virtualization.rb")).new(ohai) @plugin[:os] = "solaris2" @plugin.extend(SimpleFromFile) diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb index cc8fde42..e38d6871 100644 --- a/spec/unit/plugins/ssh_host_keys_spec.rb +++ b/spec/unit/plugins/ssh_host_keys_spec.rb @@ -21,9 +21,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "ssh_host_key plugin" do before(:each) do - @ohai = Ohai::System.new - Ohai::Loader.new(@ohai).load_plugin(File.join(PLUGIN_PATH, "ssh_host_key.rb"), "shk") - @plugin = @ohai.plugins[:shk][:plugin].new(@ohai) + ohai = Ohai::System.new + loader = Ohai::Loader.new(ohai) + @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ssh_host_key.rb")).new(ohai) @plugin[:keys] = Mash.new # Avoid using the real from_file to load the plugin => less stubbing required |