diff options
author | Claire McQuin <claire@opscode.com> | 2013-08-21 11:13:06 -0700 |
---|---|---|
committer | Claire McQuin <claire@opscode.com> | 2013-08-21 11:13:06 -0700 |
commit | 56e606073ceae86f98c58ae1e7fea6d0029fc9b5 (patch) | |
tree | dc9f226033d1573f1d97e4a94c940485009b292a | |
parent | 8a95352b53e3806166da79158b94b90e21f787c2 (diff) | |
download | ohai-56e606073ceae86f98c58ae1e7fea6d0029fc9b5.tar.gz |
add plugin loading to common spec
62 files changed, 75 insertions, 193 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 08966899..eca1cc97 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,11 @@ if Ohai::OS.collect_os == /mswin|mingw32|windows/ ENV["PATH"] = "" end +def get_plugin(plugin, ohai = Ohai::System.new, path = PLUGIN_PATH) + loader = Ohai::Loader.new(ohai) + loader.load_plugin(File.join(path, "#{plugin}.rb")).new(ohai) +end + def it_should_check_from(plugin, attribute, from, value) it "should set the #{attribute} to the value from '#{from}'" do @plugin.run diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb index 58d26cb1..375b4204 100644 --- a/spec/unit/plugins/azure_spec.rb +++ b/spec/unit/plugins/azure_spec.rb @@ -22,9 +22,7 @@ require 'open-uri' describe Ohai::System, "plugin azure" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("azure.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("azure") end describe "with azure cloud file" do diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb index 461185fd..e0e0242e 100644 --- a/spec/unit/plugins/c_spec.rb +++ b/spec/unit/plugins/c_spec.rb @@ -103,9 +103,7 @@ EOF describe Ohai::System, "plugin c" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "c.rb")).new(ohai) + @plugin = get_plugin("c") @plugin[:languages] = Mash.new #gcc diff --git a/spec/unit/plugins/chef_spec.rb b/spec/unit/plugins/chef_spec.rb index 48e00a93..0d9a206c 100644 --- a/spec/unit/plugins/chef_spec.rb +++ b/spec/unit/plugins/chef_spec.rb @@ -25,9 +25,7 @@ begin describe Ohai::System, "plugin chef" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "chef.rb")).new(ohai) + @plugin = get_plugin("chef") 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 7ceadd11..e4dc1ef3 100644 --- a/spec/unit/plugins/cloud_spec.rb +++ b/spec/unit/plugins/cloud_spec.rb @@ -19,9 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin cloud" do before do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("cloud.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("cloud") 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 13bbf239..82e4827b 100644 --- a/spec/unit/plugins/darwin/cpu_spec.rb +++ b/spec/unit/plugins/darwin/cpu_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin cpu plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("darwin/cpu.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("darwin/cpu") @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 bd18592d..08b9e1ca 100644 --- a/spec/unit/plugins/darwin/hostname_spec.rb +++ b/spec/unit/plugins/darwin/hostname_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin hostname plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("darwin/hostname.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("darwin/hostname") @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 d22d5602..6eefceef 100644 --- a/spec/unit/plugins/darwin/kernel_spec.rb +++ b/spec/unit/plugins/darwin/kernel_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin kernel plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("darwin/kernel.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("darwin/kernel") @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 fe44bfe7..d7a6cb5d 100644 --- a/spec/unit/plugins/darwin/network_spec.rb +++ b/spec/unit/plugins/darwin/network_spec.rb @@ -412,9 +412,7 @@ net.smb.fs.tcpsndbuf: 261120 net.smb.fs.tcprcvbuf: 261120 DARWIN_SYSCTL - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("darwin/network.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("darwin/network") @stdin_ifconfig = StringIO.new @stdin_arp = StringIO.new @@ -432,7 +430,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| - p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)).new(ohai) + p = get_plugin(plgn) 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 068dc266..4bfc7a7b 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -21,9 +21,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin plugin platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("darwin/platform.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("darwin/platform") + @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 d13505b0..6f13435c 100644 --- a/spec/unit/plugins/darwin/system_profiler_spec.rb +++ b/spec/unit/plugins/darwin/system_profiler_spec.rb @@ -28,9 +28,7 @@ end describe Ohai::System, "Darwin system_profiler plugin", :unix_only do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("darwin/system_profiler.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("darwin/system_profiler") 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 f5ed3bdc..bf560e9a 100644 --- a/spec/unit/plugins/dmi_spec.rb +++ b/spec/unit/plugins/dmi_spec.rb @@ -93,9 +93,8 @@ EOS describe Ohai::System, "plugin dmi" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("dmi.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("dmi") + @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 4da89d38..09742209 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -22,9 +22,7 @@ require 'open-uri' describe Ohai::System, "plugin ec2" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ec2.rb")).new(ohai) + @plugin = get_plugin("ec2") @plugin[:network] = {:interfaces => {:eth0 => {} } } end diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb index 3f821ba7..8d90905d 100644 --- a/spec/unit/plugins/erlang_spec.rb +++ b/spec/unit/plugins/erlang_spec.rb @@ -24,9 +24,7 @@ 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 - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("erlang.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("erlang") @plugin[:languages] = Mash.new @status = 0 @stdin = "" diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb index 917dc69a..f0dcd600 100644 --- a/spec/unit/plugins/eucalyptus_spec.rb +++ b/spec/unit/plugins/eucalyptus_spec.rb @@ -22,9 +22,7 @@ require 'open-uri' describe Ohai::System, "plugin eucalyptus" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "eucalyptus.rb")).new(ohai) + @plugin = get_plugin("eucalyptus") end shared_examples_for "!eucalyptus" do diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb index 81555e6e..b1afb212 100644 --- a/spec/unit/plugins/freebsd/hostname_spec.rb +++ b/spec/unit/plugins/freebsd/hostname_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD hostname plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("freebsd/hostname.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("freebsd/hostname") @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 52d0d370..079bb172 100644 --- a/spec/unit/plugins/freebsd/kernel_spec.rb +++ b/spec/unit/plugins/freebsd/kernel_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD kernel plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("freebsd/kernel.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("freebsd/kernel") @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 ce686248..76dadb98 100644 --- a/spec/unit/plugins/freebsd/platform_spec.rb +++ b/spec/unit/plugins/freebsd/platform_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD plugin platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("freebsd/platform.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("freebsd/platform") @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 fdcda147..c54ed9e8 100644 --- a/spec/unit/plugins/freebsd/virtualization_spec.rb +++ b/spec/unit/plugins/freebsd/virtualization_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "FreeBSD virtualization plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("freebsd/virtualization.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("freebsd/virtualization") @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 5add3839..b9df2c60 100644 --- a/spec/unit/plugins/gce_spec.rb +++ b/spec/unit/plugins/gce_spec.rb @@ -20,9 +20,7 @@ require 'open-uri' describe Ohai::System, "plugin gce" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("gce.rb", PLUGIN_PATH)).new(ohai) + @plugin = get_plugin("gce") end shared_examples_for "!gce" do diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb index 14222c8a..7555ac89 100644 --- a/spec/unit/plugins/groovy_spec.rb +++ b/spec/unit/plugins/groovy_spec.rb @@ -22,9 +22,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin groovy" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "groovy.rb")).new(ohai) + @plugin = get_plugin("groovy") @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 cec415ea..5891811a 100644 --- a/spec/unit/plugins/hostname_spec.rb +++ b/spec/unit/plugins/hostname_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "hostname plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "hostname.rb")).new(ohai) + @plugin = get_plugin("hostname") 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 ee2dbd38..de54b177 100644 --- a/spec/unit/plugins/java_spec.rb +++ b/spec/unit/plugins/java_spec.rb @@ -21,9 +21,7 @@ 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 - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "java.rb")).new(ohai) + @plugin = get_plugin("java") @plugin[:languages] = Mash.new @status = 0 @stdout = "" @@ -73,9 +71,7 @@ end describe Ohai::System, "plugin java (Java6 Server VM)" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "java.rb")).new(ohai) + @plugin = get_plugin("java") @plugin[:languages] = Mash.new @status = 0 @stdout = "" diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb index afa46a3f..2d6277e6 100644 --- a/spec/unit/plugins/kernel_spec.rb +++ b/spec/unit/plugins/kernel_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin kernel" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "kernel.rb")).new(ohai) + @plugin = get_plugin("kernel") @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 dcd09723..b773e4ff 100644 --- a/spec/unit/plugins/linode_spec.rb +++ b/spec/unit/plugins/linode_spec.rb @@ -22,9 +22,7 @@ describe Ohai::System, "plugin linode" do let(:hint_path_win) { 'C:\chef\ohai\hints/linode.json' } before do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linode.rb")).new(ohai) + @plugin = get_plugin("linode") @plugin[:network] = { "interfaces"=> { "eth0"=> { diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index a5720c7e..925d0553 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux cpu plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/cpu.rb")).new(ohai) + @plugin = get_plugin("linux/cpu") @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 171109d0..6ac3adf8 100644 --- a/spec/unit/plugins/linux/filesystem_spec.rb +++ b/spec/unit/plugins/linux/filesystem_spec.rb @@ -20,9 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux filesystem plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/filesystem.rb")).new(ohai) + @plugin = get_plugin("linux/filesystem") @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 416e3c36..b11b104b 100644 --- a/spec/unit/plugins/linux/hostname_spec.rb +++ b/spec/unit/plugins/linux/hostname_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux hostname plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/hostname.rb")).new(ohai) + @plugin = get_plugin("linux/hostname") @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 ae42ac51..17c3f71a 100644 --- a/spec/unit/plugins/linux/kernel_spec.rb +++ b/spec/unit/plugins/linux/kernel_spec.rb @@ -23,9 +23,7 @@ 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 - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/kernel.rb")).new(ohai) + @plugin = get_plugin("linux/kernel") @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 b5229e9e..8071a2bd 100644 --- a/spec/unit/plugins/linux/lsb_spec.rb +++ b/spec/unit/plugins/linux/lsb_spec.rb @@ -23,9 +23,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux lsb plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/lsb.rb")).new(ohai) + @plugin = get_plugin("linux/lsb") @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 fbb80542..378c2892 100644 --- a/spec/unit/plugins/linux/network_spec.rb +++ b/spec/unit/plugins/linux/network_spec.rb @@ -276,16 +276,14 @@ IP_ROUTE_SCOPE @stdin_ip_route_inet6 = StringIO.new prepare_data - - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/network.rb")).new(ohai) + + @plugin = get_plugin("linux/network") @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| - p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)).new(ohai) + p = get_plugin(plgn) 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 e293f532..4ab6bba2 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -22,9 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux plugin platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/platform.rb")).new(ohai) + @plugin = get_plugin("linux/platform") @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 9af200d7..14d26a4d 100644 --- a/spec/unit/plugins/linux/uptime_spec.rb +++ b/spec/unit/plugins/linux/uptime_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux plugin uptime" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/uptime.rb")).new(ohai) + @plugin = get_plugin("linux/uptime") @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 58f48925..ae492d20 100644 --- a/spec/unit/plugins/linux/virtualization_spec.rb +++ b/spec/unit/plugins/linux/virtualization_spec.rb @@ -20,9 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux virtualization platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "linux/virtualization.rb")).new(ohai) + @plugin = get_plugin("linux/virtualization") @plugin[:os] = "linux" @plugin.extend(SimpleFromFile) diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb index 06d3c0f3..534a9c7b 100644 --- a/spec/unit/plugins/lua_spec.rb +++ b/spec/unit/plugins/lua_spec.rb @@ -24,9 +24,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin lua" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "lua.rb")).new(ohai) + @plugin = get_plugin("lua") @plugin[:languages] = Mash.new @status = 0 @stdout = "" diff --git a/spec/unit/plugins/mono_spec.rb b/spec/unit/plugins/mono_spec.rb index 53cc19d3..54942a4a 100644 --- a/spec/unit/plugins/mono_spec.rb +++ b/spec/unit/plugins/mono_spec.rb @@ -22,9 +22,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin mono" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "mono.rb")).new(ohai) + @plugin = get_plugin("mono") @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 16267d89..e6744f83 100644 --- a/spec/unit/plugins/netbsd/hostname_spec.rb +++ b/spec/unit/plugins/netbsd/hostname_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "NetBSD hostname plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "netbsd/hostname.rb")).new(ohai) + @plugin = get_plugin("netbsd/hostname") @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 8ef1af95..91e70a4b 100644 --- a/spec/unit/plugins/netbsd/kernel_spec.rb +++ b/spec/unit/plugins/netbsd/kernel_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "NetBSD kernel plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "netbsd/kernel.rb")).new(ohai) + @plugin = get_plugin("netbsd/kernel") @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 458588ce..1c9429c6 100644 --- a/spec/unit/plugins/netbsd/platform_spec.rb +++ b/spec/unit/plugins/netbsd/platform_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "NetBSD plugin platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "netbsd/platform.rb")).new(ohai) + @plugin = get_plugin("netbsd/platform") @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 3bdc8f2f..ac5c7689 100644 --- a/spec/unit/plugins/network_spec.rb +++ b/spec/unit/plugins/network_spec.rb @@ -149,9 +149,7 @@ describe Ohai::System, "Network Plugin" do describe "with linux" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "network.rb")).new(ohai) + @plugin = get_plugin("network") @plugin["network"] = basic_data["linux"]["network"] end diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb index 4a3302b9..5a8a56ce 100644 --- a/spec/unit/plugins/nodejs_spec.rb +++ b/spec/unit/plugins/nodejs_spec.rb @@ -23,9 +23,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he describe Ohai::System, "plugin nodejs" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "nodejs.rb")).new(ohai) + @plugin = get_plugin("nodejs") @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 d4f1087e..cea24ee4 100644 --- a/spec/unit/plugins/ohai_spec.rb +++ b/spec/unit/plugins/ohai_spec.rb @@ -22,9 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin ohai" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ohai.rb")).new(ohai) + @plugin = get_plugin("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 59eaab51..003f4da3 100644 --- a/spec/unit/plugins/ohai_time_spec.rb +++ b/spec/unit/plugins/ohai_time_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin ohai_time" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ohai_time.rb")).new(ohai) + @plugin = get_plugin("ohai_time") 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 e8e5e2ec..895061a8 100644 --- a/spec/unit/plugins/openbsd/hostname_spec.rb +++ b/spec/unit/plugins/openbsd/hostname_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "OpenBSD hostname plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "openbsd/hostname.rb")).new(ohai) + @plugin = get_plugin("openbsd/hostname") @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 2c2f50b5..909dcc8d 100644 --- a/spec/unit/plugins/openbsd/kernel_spec.rb +++ b/spec/unit/plugins/openbsd/kernel_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "OpenBSD kernel plugin" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "openbsd/kernel.rb")).new(ohai) + @plugin = get_plugin("openbsd/kernel") @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 d9138553..9fd8315a 100644 --- a/spec/unit/plugins/openbsd/platform_spec.rb +++ b/spec/unit/plugins/openbsd/platform_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "OpenBSD plugin platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "openbsd/platform.rb")).new(ohai) + @plugin = get_plugin("openbsd/platform") @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 c776b603..86faa1e0 100644 --- a/spec/unit/plugins/os_spec.rb +++ b/spec/unit/plugins/os_spec.rb @@ -23,9 +23,7 @@ ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG['host_os'] describe Ohai::System, "plugin os" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "os.rb")).new(ohai) + @plugin = get_plugin("os") @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 839ef5b4..4e3a2e33 100644 --- a/spec/unit/plugins/passwd_spec.rb +++ b/spec/unit/plugins/passwd_spec.rb @@ -2,9 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin etc" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "passwd.rb")).new(ohai) + @plugin = get_plugin("passwd") 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 1c66967e..e01b8327 100644 --- a/spec/unit/plugins/perl_spec.rb +++ b/spec/unit/plugins/perl_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin perl" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "perl.rb")).new(ohai) + @plugin = get_plugin("perl") @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 36691dec..ecc61390 100644 --- a/spec/unit/plugins/php_spec.rb +++ b/spec/unit/plugins/php_spec.rb @@ -25,9 +25,7 @@ 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 - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "php.rb")).new(ohai) + @plugin = get_plugin("php") @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 6dc20469..cf743a96 100644 --- a/spec/unit/plugins/platform_spec.rb +++ b/spec/unit/plugins/platform_spec.rb @@ -21,9 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "platform.rb")).new(ohai) + @plugin = get_plugin("platform") @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 57c52a98..e8c2f0d6 100644 --- a/spec/unit/plugins/python_spec.rb +++ b/spec/unit/plugins/python_spec.rb @@ -23,9 +23,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin python" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "python.rb")).new(ohai) + @plugin = get_plugin("python") @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 be87ddb9..bb8016f4 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -19,9 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Ohai::System, "plugin rackspace" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "rackspace.rb")).new(ohai) + @plugin = get_plugin("rackspace") @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 ee7e0fd6..9e463dd9 100644 --- a/spec/unit/plugins/root_group_spec.rb +++ b/spec/unit/plugins/root_group_spec.rb @@ -22,9 +22,7 @@ ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG['host_os'] describe Ohai::System, 'root_group' do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "root_group.rb")).new(ohai) + @plugin = get_plugin("root_group") end describe 'unix platform', :unix_only do diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb index 76f76850..6c3a3def 100644 --- a/spec/unit/plugins/ruby_spec.rb +++ b/spec/unit/plugins/ruby_spec.rb @@ -24,9 +24,7 @@ ruby_bin = File.join(::RbConfig::CONFIG['bindir'], ::RbConfig::CONFIG['ruby_inst describe Ohai::System, "plugin ruby" do before(:all) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ruby.rb")).new(ohai) + @plugin = get_plugin("ruby") @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 32658c33..45fec414 100644 --- a/spec/unit/plugins/sigar/network_route_spec.rb +++ b/spec/unit/plugins/sigar/network_route_spec.rb @@ -32,9 +32,8 @@ describe Ohai::System, "Sigar network route plugin" do if sigar_available before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.expand_path("sigar/network_route.rb", PLUGIN_PATH)).new(ohai) + @ohai = Ohai::System.new + @plugin = get_plugin("sigar/network_route", @ohai) @sigar = double("Sigar") @net_info_conf={ :default_gateway => "192.168.1.254", @@ -124,15 +123,13 @@ 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| - p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)) - p.new(ohai).run + get_plugin(plgn, @ohai).run end @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| - p = loader.load_plugin(File.expand_path("#{plgn}.rb", PLUGIN_PATH)) - p.new(ohai).run + get_plugin(plgn, @ohai).run end @plugin.run diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb index 0ac46bfb..ff00c92c 100644 --- a/spec/unit/plugins/solaris2/hostname_spec.rb +++ b/spec/unit/plugins/solaris2/hostname_spec.rb @@ -20,9 +20,7 @@ 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 - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/hostname.rb")).new(ohai) + @plugin = get_plugin("solaris2/hostname") @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 5b0981c3..23a6505f 100644 --- a/spec/unit/plugins/solaris2/kernel_spec.rb +++ b/spec/unit/plugins/solaris2/kernel_spec.rb @@ -134,9 +134,7 @@ describe Ohai::System, "Solaris2.X kernel plugin" do TOOMUCH before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/kernel.rb")).new(ohai) + @plugin = get_plugin("solaris2/kernel") @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 27259c91..759bba63 100644 --- a/spec/unit/plugins/solaris2/network_spec.rb +++ b/spec/unit/plugins/solaris2/network_spec.rb @@ -89,9 +89,7 @@ ROUTE_GET @ifconfig_lines = solaris_ifconfig.split("\n") - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/network.rb")).new(ohai) + @plugin = get_plugin("solaris2/network") @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 306b53ef..9568335a 100644 --- a/spec/unit/plugins/solaris2/platform_spec.rb +++ b/spec/unit/plugins/solaris2/platform_spec.rb @@ -20,9 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Solaris plugin platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/platform.rb")).new(ohai) + @plugin = get_plugin("solaris2/platform") @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 2acc8b5d..be8be05a 100644 --- a/spec/unit/plugins/solaris2/virtualization_spec.rb +++ b/spec/unit/plugins/solaris2/virtualization_spec.rb @@ -20,9 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Solaris virtualization platform" do before(:each) do - ohai = Ohai::System.new - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "solaris2/virtualization.rb")).new(ohai) + @plugin = get_plugin("solaris2/virtualization") @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 e38d6871..4ead4478 100644 --- a/spec/unit/plugins/ssh_host_keys_spec.rb +++ b/spec/unit/plugins/ssh_host_keys_spec.rb @@ -21,9 +21,7 @@ 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 - loader = Ohai::Loader.new(ohai) - @plugin = loader.load_plugin(File.join(PLUGIN_PATH, "ssh_host_key.rb")).new(ohai) + @plugin = get_plugin("ssh_host_key") @plugin[:keys] = Mash.new # Avoid using the real from_file to load the plugin => less stubbing required |