diff options
author | Claire McQuin <claire@opscode.com> | 2013-10-08 15:42:05 -0700 |
---|---|---|
committer | Claire McQuin <claire@opscode.com> | 2013-10-17 12:07:30 -0700 |
commit | 833041f3066838994fe1121f1e5d668fee852dc6 (patch) | |
tree | 5f1f89c6e2a243822a2a2769aa41680e01b55952 | |
parent | 56350ad5b7a79e24d6debe03bd64cbbad5a41623 (diff) | |
download | ohai-833041f3066838994fe1121f1e5d668fee852dc6.tar.gz |
automatically clear plugins and constants between tests
66 files changed, 39 insertions, 527 deletions
diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb index 1fc2841e..af412110 100644 --- a/lib/ohai/plugins/gce.rb +++ b/lib/ohai/plugins/gce.rb @@ -18,11 +18,10 @@ require 'ohai/mixin/gce_metadata' Ohai.plugin(:GCE) do include Ohai::Mixin::GCEMetadata + GOOGLE_SYSFS_DMI = '/sys/firmware/dmi/entries/1-0/raw' provides "gce" - - GOOGLE_SYSFS_DMI = '/sys/firmware/dmi/entries/1-0/raw' - + #https://developers.google.com/compute/docs/instances#dmi def has_google_dmi? ::File.read(GOOGLE_SYSFS_DMI).include?('Google') diff --git a/spec/ohai/dsl/plugin_spec.rb b/spec/ohai/dsl/plugin_spec.rb index c1589838..e675544b 100644 --- a/spec/ohai/dsl/plugin_spec.rb +++ b/spec/ohai/dsl/plugin_spec.rb @@ -81,12 +81,6 @@ describe Ohai::DSL::Plugin::VersionVII do @name = :Test end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, @name) - Ohai::NamedPlugin.send(:remove_const, @name) - end - end - it "should log a warning when a version 6 plugin with the same name exists" do name_str = @name.to_s.downcase Ohai.v6plugin(name_str) { } @@ -237,12 +231,6 @@ describe Ohai::DSL::Plugin::VersionVI do @name_sym = :Test end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, @name_sym) - Ohai::NamedPlugin.send(:remove_const, @name_sym) - end - end - it "should log to debug if a plugin with the same name has been defined" do Ohai.plugin(@name_sym) { } Ohai::Log.should_receive(:debug).with(/Already loaded plugin #{@name_sym}/) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 89017881..3b150141 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,6 +14,38 @@ Ohai::Config[:log_level] = :error PLUGIN_PATH = File.expand_path("../../lib/ohai/plugins", __FILE__) SPEC_PLUGIN_PATH = File.expand_path("../data/plugins", __FILE__) +RSpec.configure do |config| + config.before(:each) { @object_pristine = Object.clone } + config.after(:each) { remove_constants } +end + +def remove_constants + new_object_constants = Object.constants - @object_pristine.constants + new_object_constants.each do |constant| + Object.send(:remove_const, constant) unless Object.const_get(constant).is_a?(Module) + end + + recursive_remove_constants(Ohai::NamedPlugin) +end + +def recursive_remove_constants(object) + if object.respond_to?(:constants) + object.constants.each do |const| + next unless strict_const_defined?(object, const) + recursive_remove_constants(object.const_get(const)) + object.send(:remove_const, const) + end + end +end + +def strict_const_defined?(object, const) + if object.method(:const_defined?).arity == 1 + object.const_defned?(const) + else + object.const_defined?(const, false) + end +end + if Ohai::OS.collect_os == /mswin|mingw32|windows/ ENV["PATH"] = "" end diff --git a/spec/unit/loader_spec.rb b/spec/unit/loader_spec.rb index 5d8a39af..b6353061 100644 --- a/spec/unit/loader_spec.rb +++ b/spec/unit/loader_spec.rb @@ -41,12 +41,6 @@ describe Ohai::Loader do @loader.stub(:collect_provides).and_return({}) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, @name) - Ohai::NamedPlugin.send(:remove_const, @name) - end - end - it "should log a warning if a plugin cannot be loaded" do Ohai::Log.should_receive(:warn).with(/Unable to open or read plugin/) IO.stub(:read).with(anything()).and_raise(IOError) @@ -93,12 +87,6 @@ EOF @loader = Ohai::Loader.new(@ohai) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, @name) - Ohai::NamedPlugin.send(:remove_const, @name) - end - end - it "should add provided attributes to Ohai" do klass = Ohai.plugin(@name) { provides("attr") } plugin = klass.new(@ohai, @path) diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb index 64aa3785..375b4204 100644 --- a/spec/unit/plugins/azure_spec.rb +++ b/spec/unit/plugins/azure_spec.rb @@ -25,12 +25,6 @@ describe Ohai::System, "plugin azure" do @plugin = get_plugin("azure") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Azure) - Ohai::NamedPlugin.send(:remove_const, :Azure) - end - end - describe "with azure cloud file" do before(:each) do File.stub(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true) diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb index 2077f119..33daa21c 100644 --- a/spec/unit/plugins/c_spec.rb +++ b/spec/unit/plugins/c_spec.rb @@ -122,12 +122,6 @@ describe Ohai::System, "plugin c" do @plugin.stub(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :C) - Ohai::NamedPlugin.send(:remove_const, :C) - end - end - #gcc it "should get the gcc version from running gcc -v" do @plugin.should_receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC)) diff --git a/spec/unit/plugins/chef_spec.rb b/spec/unit/plugins/chef_spec.rb index fc6d083a..e12b202b 100644 --- a/spec/unit/plugins/chef_spec.rb +++ b/spec/unit/plugins/chef_spec.rb @@ -28,12 +28,6 @@ begin @plugin = get_plugin("chef") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Chef) - Ohai::NamedPlugin.send(:remove_const, :Chef) - end - end - it "should set [:chef_packages][:chef][:version] to the current chef version", :if => defined?(Chef) do @plugin.run @plugin[:chef_packages][:chef][:version].should == Chef::VERSION diff --git a/spec/unit/plugins/cloud_spec.rb b/spec/unit/plugins/cloud_spec.rb index 111eee15..78e7740f 100644 --- a/spec/unit/plugins/cloud_spec.rb +++ b/spec/unit/plugins/cloud_spec.rb @@ -22,12 +22,6 @@ describe Ohai::System, "plugin cloud" do @plugin = get_plugin("cloud") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Cloud) - Ohai::NamedPlugin.send(:remove_const, :Cloud) - end - end - describe "with no cloud mashes" do it "doesn't populate the cloud data" do @plugin[:ec2] = nil diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb index ae355f45..63fd1796 100644 --- a/spec/unit/plugins/darwin/cpu_spec.rb +++ b/spec/unit/plugins/darwin/cpu_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "Darwin cpu plugin" do @plugin.stub(:shell_out).with("sysctl -n hw.logicalcpu").and_return(mock_shell_out(0, "2", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :CPU) - Ohai::NamedPlugin.send(:remove_const, :CPU) - end - end - it "should set cpu[:total] to 2" do @plugin.run @plugin[:cpu][:total].should == 2 diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb index 0ef7cc91..c2d9a5dd 100644 --- a/spec/unit/plugins/darwin/hostname_spec.rb +++ b/spec/unit/plugins/darwin/hostname_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "Darwin hostname plugin" do @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.bethell", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Hostname) - Ohai::NamedPlugin.send(:remove_const, :Hostname) - end - end - it_should_check_from("darwin::hostname", "hostname", "hostname -s", "katie") it_should_check_from("darwin::hostname", "fqdn", "hostname", "katie.bethell") diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb index 6cc587e5..d2033a45 100644 --- a/spec/unit/plugins/darwin/kernel_spec.rb +++ b/spec/unit/plugins/darwin/kernel_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "Darwin kernel plugin" do @plugin.should_receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Kernel) - Ohai::NamedPlugin.send(:remove_const, :Kernel) - end - end - it "should not set kernel_machine to x86_64" do @plugin.stub(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", "")) @plugin.run diff --git a/spec/unit/plugins/darwin/network_spec.rb b/spec/unit/plugins/darwin/network_spec.rb index 425a4b6d..2cf5ed04 100644 --- a/spec/unit/plugins/darwin/network_spec.rb +++ b/spec/unit/plugins/darwin/network_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Darwin Network Plugin" do - before do + before(:each) do @darwin_ifconfig = <<-DARWIN_IFCONFIG lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=3<RXCSUM,TXCSUM> @@ -429,14 +429,8 @@ net.smb.fs.tcprcvbuf: 261120 @plugin.stub(:shell_out).with("netstat -i -d -l -b -n") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Network) - Ohai::NamedPlugin.send(:remove_const, :Network) - end - end - describe "gathering IP layer address info" do - before do + before(:each) do @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @darwin_arp, "")) @plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @darwin_ifconfig, "")) @plugin.stub(:shell_out).with("netstat -i -d -l -b -n").and_return(mock_shell_out(0, @darwin_netstat, "")) diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb index c700c8cb..bae1ca72 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -26,13 +26,7 @@ describe Ohai::System, "Darwin plugin platform" do @stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33" @plugin.stub(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, "")) end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Platform) - Ohai::NamedPlugin.send(:remove_const, :Platform) - end - end - + it "should run sw_vers" do @plugin.should_receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, "")) @plugin.run diff --git a/spec/unit/plugins/darwin/system_profiler_spec.rb b/spec/unit/plugins/darwin/system_profiler_spec.rb index 604b40fe..5efad018 100644 --- a/spec/unit/plugins/darwin/system_profiler_spec.rb +++ b/spec/unit/plugins/darwin/system_profiler_spec.rb @@ -32,12 +32,6 @@ describe Ohai::System, "Darwin system_profiler plugin", :unix_only do @plugin.stub(:collect_os).and_return(:darwin) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :SystemProfile) - Ohai::NamedPlugin.send(:remove_const, :SystemProfile) - end - end - it "should return the right serial number" do mini_cmd = "system_profiler -xml -detailLevel mini SPParallelATAData SPAudioData SPBluetoothData" mini_cmd += " SPCardReaderData SPDiagnosticsData SPDiscBurningData SPEthernetData SPFibreChannelData" diff --git a/spec/unit/plugins/dmi_spec.rb b/spec/unit/plugins/dmi_spec.rb index ea38aca2..9d75e066 100644 --- a/spec/unit/plugins/dmi_spec.rb +++ b/spec/unit/plugins/dmi_spec.rb @@ -98,12 +98,6 @@ describe Ohai::System, "plugin dmi" do @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :DMI) - Ohai::NamedPlugin.send(:remove_const, :DMI) - end - end - it "should run dmidecode" do @plugin.should_receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, "")) @plugin.run diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb index 199426a6..09742209 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -26,12 +26,6 @@ describe Ohai::System, "plugin ec2" do @plugin[:network] = {:interfaces => {:eth0 => {} } } end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :EC2) - Ohai::NamedPlugin.send(:remove_const, :EC2) - end - end - shared_examples_for "!ec2" do it "should NOT attempt to fetch the ec2 metadata" do @plugin.should_not_receive(:http_client) diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb index 0039a8fc..f0dcd600 100644 --- a/spec/unit/plugins/eucalyptus_spec.rb +++ b/spec/unit/plugins/eucalyptus_spec.rb @@ -25,12 +25,6 @@ describe Ohai::System, "plugin eucalyptus" do @plugin = get_plugin("eucalyptus") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Eucalyptus) - Ohai::NamedPlugin.send(:remove_const, :Eucalyptus) - end - end - shared_examples_for "!eucalyptus" do it "should NOT attempt to fetch the eucalyptus metadata" do OpenURI.should_not_receive(:open) diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb index b47859db..cb71b230 100644 --- a/spec/unit/plugins/freebsd/hostname_spec.rb +++ b/spec/unit/plugins/freebsd/hostname_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "FreeBSD hostname plugin" do @plugin.stub(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Hostname) - Ohai::NamedPlugin.send(:remove_const, :Hostname) - end - end - it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie") it_should_check_from("freebsd::hostname", "fqdn", "hostname -f", "katie.bethell") diff --git a/spec/unit/plugins/freebsd/kernel_spec.rb b/spec/unit/plugins/freebsd/kernel_spec.rb index 4b8c5292..ccfb19d7 100644 --- a/spec/unit/plugins/freebsd/kernel_spec.rb +++ b/spec/unit/plugins/freebsd/kernel_spec.rb @@ -29,12 +29,6 @@ describe Ohai::System, "FreeBSD kernel plugin" do @plugin.stub(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Kernel) - Ohai::NamedPlugin.send(:remove_const, :Kernel) - end - end - it "should set the kernel_os to the kernel_name value" do @plugin.run @plugin[:kernel][:os].should == @plugin[:kernel][:name] diff --git a/spec/unit/plugins/freebsd/platform_spec.rb b/spec/unit/plugins/freebsd/platform_spec.rb index 32f2138d..a38db60e 100644 --- a/spec/unit/plugins/freebsd/platform_spec.rb +++ b/spec/unit/plugins/freebsd/platform_spec.rb @@ -26,13 +26,7 @@ describe Ohai::System, "FreeBSD plugin platform" do @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", "")) @plugin.stub(:collect_os).and_return(:freebsd) end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Platform) - Ohai::NamedPlugin.send(:remove_const, :Platform) - end - end - + it "should set platform to lowercased lsb[:id]" do @plugin.run @plugin[:platform].should == "freebsd" diff --git a/spec/unit/plugins/freebsd/virtualization_spec.rb b/spec/unit/plugins/freebsd/virtualization_spec.rb index 983f7aab..1072f051 100644 --- a/spec/unit/plugins/freebsd/virtualization_spec.rb +++ b/spec/unit/plugins/freebsd/virtualization_spec.rb @@ -30,12 +30,6 @@ describe Ohai::System, "FreeBSD virtualization plugin" do @plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Virtualization) - Ohai::NamedPlugin.send(:remove_const, :Virtualization) - end - end - context "jails" do it "detects we are in a jail" do @plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", "")) diff --git a/spec/unit/plugins/gce_spec.rb b/spec/unit/plugins/gce_spec.rb index ed98e662..b9df2c60 100644 --- a/spec/unit/plugins/gce_spec.rb +++ b/spec/unit/plugins/gce_spec.rb @@ -23,12 +23,6 @@ describe Ohai::System, "plugin gce" do @plugin = get_plugin("gce") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :GCE) - Ohai::NamedPlugin.send(:remove_const, :GCE) - end - end - shared_examples_for "!gce" do it "should NOT attempt to fetch the gce metadata" do @plugin.should_not_receive(:http_client) diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb index 15a187f1..5d072d16 100644 --- a/spec/unit/plugins/groovy_spec.rb +++ b/spec/unit/plugins/groovy_spec.rb @@ -29,12 +29,6 @@ describe Ohai::System, "plugin groovy" do @plugin.stub(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Groovy) - Ohai::NamedPlugin.send(:remove_const, :Groovy) - end - end - it "should get the groovy version from running groovy -v" do @plugin.should_receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, "")) @plugin.run diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb index c1c404df..38860f0f 100644 --- a/spec/unit/plugins/hostname_spec.rb +++ b/spec/unit/plugins/hostname_spec.rb @@ -25,12 +25,6 @@ describe Ohai::System, "hostname plugin" do @plugin.stub(:collect_os).and_return(:default) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Hostname) - Ohai::NamedPlugin.send(:remove_const, :Hostname) - end - end - it "should set the domain to everything after the first dot of the fqdn" do @plugin[:fqdn] = "katie.bethell" @plugin.run diff --git a/spec/unit/plugins/java_spec.rb b/spec/unit/plugins/java_spec.rb index 49bc7308..7258ce66 100644 --- a/spec/unit/plugins/java_spec.rb +++ b/spec/unit/plugins/java_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do @plugin.stub(:shell_out).with("java -version").and_return(mock_shell_out(0, "", @stderr)) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Java) - Ohai::NamedPlugin.send(:remove_const, :Java) - end - end - it "should run java -version" do @plugin.should_receive(:shell_out).with("java -version").and_return(mock_shell_out(0, "", @stderr)) @plugin.run diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb index db7902cf..737573c6 100644 --- a/spec/unit/plugins/kernel_spec.rb +++ b/spec/unit/plugins/kernel_spec.rb @@ -30,12 +30,6 @@ describe Ohai::System, "plugin kernel" do @plugin.stub(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux\n", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Kernel) - Ohai::NamedPlugin.send(:remove_const, :Kernel) - end - end - it_should_check_from_mash("kernel", "name", "uname -s", [0, "Darwin\n", ""]) it_should_check_from_mash("kernel", "release", "uname -r", [0, "9.5.0\n", ""]) it_should_check_from_mash("kernel", "version", "uname -v", [0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""]) diff --git a/spec/unit/plugins/linode_spec.rb b/spec/unit/plugins/linode_spec.rb index 30bc76ab..b773e4ff 100644 --- a/spec/unit/plugins/linode_spec.rb +++ b/spec/unit/plugins/linode_spec.rb @@ -46,12 +46,6 @@ describe Ohai::System, "plugin linode" do } end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Linode) - Ohai::NamedPlugin.send(:remove_const, :Linode) - end - end - shared_examples_for "!linode" do it "does not create the linode mash" do @plugin.run diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index fe804512..5f55eb5f 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -46,12 +46,6 @@ describe Ohai::System, "Linux cpu plugin" do and_yield("clflush size : 32") File.stub(:open).with("/proc/cpuinfo").and_return(@double_file) end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :CPU) - Ohai::NamedPlugin.send(:remove_const, :CPU) - end - end it "should set cpu[:total] to 1" do @plugin.run diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb index 5ce7f94c..cdd601b5 100644 --- a/spec/unit/plugins/linux/filesystem_spec.rb +++ b/spec/unit/plugins/linux/filesystem_spec.rb @@ -33,12 +33,6 @@ describe Ohai::System, "Linux filesystem plugin" do File.stub(:exists?).with("/proc/mounts").and_return(false) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Filesystem) - Ohai::NamedPlugin.send(:remove_const, :Filesystem) - end - end - describe "when gathering filesystem usage data from df" do before(:each) do @stdout = <<-DF diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb index e1a8a5d3..0715a135 100644 --- a/spec/unit/plugins/linux/hostname_spec.rb +++ b/spec/unit/plugins/linux/hostname_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "Linux hostname plugin" do @plugin.stub(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Hostname) - Ohai::NamedPlugin.send(:remove_const, :Hostname) - end - end - it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie") it_should_check_from("linux::hostname", "fqdn", "hostname --fqdn", "katie.bethell") diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb index bb2cba31..068b8f10 100644 --- a/spec/unit/plugins/linux/kernel_spec.rb +++ b/spec/unit/plugins/linux/kernel_spec.rb @@ -41,12 +41,6 @@ ENV_LSMOD @plugin.run end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Kernel) - Ohai::NamedPlugin.send(:remove_const, :Kernel) - end - end - it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", [0, "Linux", ""]) test_plugin([ "kernel" ], [ "uname", "env" ]) do | p | diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb index 219ff0b9..6863170f 100644 --- a/spec/unit/plugins/linux/lsb_spec.rb +++ b/spec/unit/plugins/linux/lsb_spec.rb @@ -28,12 +28,6 @@ describe Ohai::System, "Linux lsb plugin" do @plugin.extend(SimpleFromFile) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :LSB) - Ohai::NamedPlugin.send(:remove_const, :LSB) - end - end - describe "on systems with /etc/lsb-release" do before(:each) do @double_file = double("/etc/lsb-release") diff --git a/spec/unit/plugins/linux/network_spec.rb b/spec/unit/plugins/linux/network_spec.rb index a2b90d8c..a3ae46a2 100644 --- a/spec/unit/plugins/linux/network_spec.rb +++ b/spec/unit/plugins/linux/network_spec.rb @@ -259,12 +259,6 @@ IP_ROUTE_SCOPE @plugin.stub(:shell_out).with("arp -an").and_return([0, @linux_arp_an, ""]) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Network) - Ohai::NamedPlugin.send(:remove_const, :Network) - end - end - ["ifconfig","iproute2"].each do |network_method| describe "gathering IP layer address info via #{network_method}" do diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 7eef92ce..190eec7d 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -37,13 +37,7 @@ describe Ohai::System, "Linux plugin platform" do File.stub(:exists?).with("/etc/oracle-release").and_return(false) File.stub(:exists?).with("/usr/bin/raspi-config").and_return(false) end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Platform) - Ohai::NamedPlugin.send(:remove_const, :Platform) - end - end - + describe "on lsb compliant distributions" do before(:each) do @plugin[:lsb][:id] = "Ubuntu" diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb index 1beea6fc..0f17b484 100644 --- a/spec/unit/plugins/linux/uptime_spec.rb +++ b/spec/unit/plugins/linux/uptime_spec.rb @@ -26,12 +26,6 @@ describe Ohai::System, "Linux plugin uptime" do @double_file = double("/proc/uptime", { :gets => "18423 989" }) File.stub(:open).with("/proc/uptime").and_return(@double_file) end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Uptime) - Ohai::NamedPlugin.send(:remove_const, :Uptime) - end - end it "should set uptime_seconds to uptime" do @plugin.run diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb index 415b7945..dfd8c3e4 100644 --- a/spec/unit/plugins/linux/virtualization_spec.rb +++ b/spec/unit/plugins/linux/virtualization_spec.rb @@ -35,12 +35,6 @@ describe Ohai::System, "Linux virtualization platform" do File.stub(:exists?).with("/proc/vz").and_return(false) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Virtualization) - Ohai::NamedPlugin.send(:remove_const, :Virtualization) - end - end - describe "when we are checking for xen" do it "should set xen guest if /proc/xen exists but /proc/xen/capabilities does not" do File.should_receive(:exists?).with("/proc/xen").and_return(true) diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb index 80ee6400..8dff19b6 100644 --- a/spec/unit/plugins/lua_spec.rb +++ b/spec/unit/plugins/lua_spec.rb @@ -30,12 +30,6 @@ describe Ohai::System, "plugin lua" do @plugin.stub(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr)) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Lua) - Ohai::NamedPlugin.send(:remove_const, :Lua) - end - end - it "should get the lua version from running lua -v" do @plugin.should_receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr)) @plugin.run diff --git a/spec/unit/plugins/mono_spec.rb b/spec/unit/plugins/mono_spec.rb index d3a79e12..2d71d83e 100644 --- a/spec/unit/plugins/mono_spec.rb +++ b/spec/unit/plugins/mono_spec.rb @@ -28,12 +28,6 @@ describe Ohai::System, "plugin mono" do @plugin.stub(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Mono) - Ohai::NamedPlugin.send(:remove_const, :Mono) - end - end - it "should get the mono version from running mono -V" do @plugin.should_receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, "")) @plugin.run diff --git a/spec/unit/plugins/netbsd/hostname_spec.rb b/spec/unit/plugins/netbsd/hostname_spec.rb index 0f5f54b0..b77bf696 100644 --- a/spec/unit/plugins/netbsd/hostname_spec.rb +++ b/spec/unit/plugins/netbsd/hostname_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "NetBSD hostname plugin" do @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.bethell", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Hostname) - Ohai::NamedPlugin.send(:remove_const, :Hostname) - end - end - it_should_check_from("netbsd::hostname", "hostname", "hostname -s", "katie") it_should_check_from("netbsd::hostname", "fqdn", "hostname", "katie.bethell") diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb index f79518e0..f08f2caa 100644 --- a/spec/unit/plugins/netbsd/kernel_spec.rb +++ b/spec/unit/plugins/netbsd/kernel_spec.rb @@ -29,13 +29,6 @@ describe Ohai::System, "NetBSD kernel plugin" do @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/bin/modstat" )}").and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Kernel) - Ohai::NamedPlugin.send(:remove_const, :Kernel) - end - end - - it "should set the kernel_os to the kernel_name value" do @plugin.run @plugin[:kernel][:os].should == @plugin[:kernel][:name] diff --git a/spec/unit/plugins/netbsd/platform_spec.rb b/spec/unit/plugins/netbsd/platform_spec.rb index 004126ee..f1a91758 100644 --- a/spec/unit/plugins/netbsd/platform_spec.rb +++ b/spec/unit/plugins/netbsd/platform_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "NetBSD plugin platform" do @@ -26,12 +25,6 @@ describe Ohai::System, "NetBSD plugin platform" do @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", "")) @plugin.stub(:collect_os).and_return(:netbsd) end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Platform) - Ohai::NamedPlugin.send(:remove_const, :Platform) - end - end it "should set platform to lowercased lsb[:id]" do @plugin.run diff --git a/spec/unit/plugins/network_spec.rb b/spec/unit/plugins/network_spec.rb index 07ed0c8c..27354bf7 100644 --- a/spec/unit/plugins/network_spec.rb +++ b/spec/unit/plugins/network_spec.rb @@ -290,12 +290,6 @@ describe Ohai::System, "Network Plugin" do @plugin["network"] = basic_data["linux"]["network"] end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :NetworkAddresses) - Ohai::NamedPlugin.send(:remove_const, :NetworkAddresses) - end - end - describe "when the linux::network plugin hasn't set any of {ip,ip6,mac}address attributes" do describe "simple setup" do it_does_not_fail diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb index 286bdf77..15a596af 100644 --- a/spec/unit/plugins/nodejs_spec.rb +++ b/spec/unit/plugins/nodejs_spec.rb @@ -29,12 +29,6 @@ describe Ohai::System, "plugin nodejs" do @plugin.stub(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Nodejs) - Ohai::NamedPlugin.send(:remove_const, :Nodejs) - end - end - it "should get the nodejs version from running node -v" do @plugin.should_receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, "")) @plugin.run diff --git a/spec/unit/plugins/ohai_spec.rb b/spec/unit/plugins/ohai_spec.rb index 785aa3fd..cea24ee4 100644 --- a/spec/unit/plugins/ohai_spec.rb +++ b/spec/unit/plugins/ohai_spec.rb @@ -24,12 +24,6 @@ describe Ohai::System, "plugin ohai" do before(:each) do @plugin = get_plugin("ohai") end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Ohai) - Ohai::NamedPlugin.send(:remove_const, :Ohai) - end - end it "should set [:chef_packages][:ohai][:version] to the current version" do @plugin.run diff --git a/spec/unit/plugins/ohai_time_spec.rb b/spec/unit/plugins/ohai_time_spec.rb index e000a985..003f4da3 100644 --- a/spec/unit/plugins/ohai_time_spec.rb +++ b/spec/unit/plugins/ohai_time_spec.rb @@ -23,12 +23,6 @@ describe Ohai::System, "plugin ohai_time" do before(:each) do @plugin = get_plugin("ohai_time") end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :OhaiTime) - Ohai::NamedPlugin.send(:remove_const, :OhaiTime) - end - end it "should get the current time" do Time.should_receive(:now) diff --git a/spec/unit/plugins/openbsd/hostname_spec.rb b/spec/unit/plugins/openbsd/hostname_spec.rb index 7b6e47ed..9c75c0f2 100644 --- a/spec/unit/plugins/openbsd/hostname_spec.rb +++ b/spec/unit/plugins/openbsd/hostname_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "OpenBSD hostname plugin" do @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.bethell", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Hostname) - Ohai::NamedPlugin.send(:remove_const, :Hostname) - end - end - it_should_check_from("openbsd::hostname", "hostname", "hostname -s", "katie") it_should_check_from("openbsd::hostname", "fqdn", "hostname", "katie.bethell") diff --git a/spec/unit/plugins/openbsd/kernel_spec.rb b/spec/unit/plugins/openbsd/kernel_spec.rb index c7732862..1d1643b5 100644 --- a/spec/unit/plugins/openbsd/kernel_spec.rb +++ b/spec/unit/plugins/openbsd/kernel_spec.rb @@ -29,13 +29,6 @@ describe Ohai::System, "OpenBSD kernel plugin" do @plugin.stub(:shell_out).with( Ohai.abs_path( "/usr/bin/modstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Kernel) - Ohai::NamedPlugin.send(:remove_const, :Kernel) - end - end - - it "should set the kernel_os to the kernel_name value" do @plugin.run @plugin[:kernel][:os].should == @plugin[:kernel][:name] diff --git a/spec/unit/plugins/openbsd/platform_spec.rb b/spec/unit/plugins/openbsd/platform_spec.rb index 7a3dcf85..915323ef 100644 --- a/spec/unit/plugins/openbsd/platform_spec.rb +++ b/spec/unit/plugins/openbsd/platform_spec.rb @@ -27,17 +27,6 @@ describe Ohai::System, "OpenBSD plugin platform" do @plugin.stub(:collect_os).and_return(:openbsd) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Platform) - Ohai::NamedPlugin.send(:remove_const, :Platform) - end - end - - it "should set platform to lowercased lsb[:id]" do - @plugin.run - @plugin[:platform].should == "openbsd" - end - it "should set platform_version to lsb[:release]" do @plugin.run @plugin[:platform_version].should == "4.5" diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb index 8571e37e..2f5df02f 100644 --- a/spec/unit/plugins/os_spec.rb +++ b/spec/unit/plugins/os_spec.rb @@ -30,9 +30,6 @@ describe Ohai::System, "plugin os" do after do ::RbConfig::CONFIG['host_os'] = ORIGINAL_CONFIG_HOST_OS - if Ohai::NamedPlugin.send(:const_defined?, :OS) - Ohai::NamedPlugin.send(:remove_const, :OS) - end end it "should set os_version to kernel_release" do diff --git a/spec/unit/plugins/passwd_spec.rb b/spec/unit/plugins/passwd_spec.rb index a3294432..4e3a2e33 100644 --- a/spec/unit/plugins/passwd_spec.rb +++ b/spec/unit/plugins/passwd_spec.rb @@ -5,12 +5,6 @@ describe Ohai::System, "plugin etc" do @plugin = get_plugin("passwd") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Passwd) - Ohai::NamedPlugin.send(:remove_const, :Passwd) - end - end - PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos) GroupEntry = Struct.new(:name, :gid, :mem) diff --git a/spec/unit/plugins/perl_spec.rb b/spec/unit/plugins/perl_spec.rb index f69be6f2..1922a3cf 100644 --- a/spec/unit/plugins/perl_spec.rb +++ b/spec/unit/plugins/perl_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "plugin perl" do @plugin.stub(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Perl) - Ohai::NamedPlugin.send(:remove_const, :Perl) - end - end - it "should run perl -V:version -V:archname" do @plugin.should_receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, "")) @plugin.run diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb index a843389e..fac70509 100644 --- a/spec/unit/plugins/php_spec.rb +++ b/spec/unit/plugins/php_spec.rb @@ -31,12 +31,6 @@ describe Ohai::System, "plugin php" do @plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :PHP) - Ohai::NamedPlugin.send(:remove_const, :PHP) - end - end - it "should get the php version from running php -V" do @plugin.should_receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, "")) @plugin.run diff --git a/spec/unit/plugins/platform_spec.rb b/spec/unit/plugins/platform_spec.rb index 4d0bba4c..704038fc 100644 --- a/spec/unit/plugins/platform_spec.rb +++ b/spec/unit/plugins/platform_spec.rb @@ -27,12 +27,6 @@ describe Ohai::System, "plugin platform" do @plugin[:os_version] = 'poop' end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Platform) - Ohai::NamedPlugin.send(:remove_const, :Platform) - end - end - it "should set the platform and platform family to the os if it was not set earlier" do @plugin.run @plugin[:platform].should eql("monkey") diff --git a/spec/unit/plugins/python_spec.rb b/spec/unit/plugins/python_spec.rb index c8be32b9..68ef48c6 100644 --- a/spec/unit/plugins/python_spec.rb +++ b/spec/unit/plugins/python_spec.rb @@ -28,12 +28,6 @@ describe Ohai::System, "plugin python" do @stdout = "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" @plugin.stub(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(0, @stdout, "")) end - - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Python) - Ohai::NamedPlugin.send(:remove_const, :Python) - end - end it "should get the python version from printing sys.version and sys.platform" do @plugin.should_receive(:shell_out).with("python -c \"import sys; print sys.version\"").and_return(mock_shell_out(0, @stdout, "")) diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index 5a53044a..357905c8 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -69,12 +69,6 @@ describe Ohai::System, "plugin rackspace" do @plugin.stub(:shell_out).and_return(mock_shell_out(1, "", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Rackspace) - Ohai::NamedPlugin.send(:remove_const, :Rackspace) - end - end - shared_examples_for "!rackspace" do it "should NOT create rackspace" do @plugin.run diff --git a/spec/unit/plugins/root_group_spec.rb b/spec/unit/plugins/root_group_spec.rb index a839468d..9e463dd9 100644 --- a/spec/unit/plugins/root_group_spec.rb +++ b/spec/unit/plugins/root_group_spec.rb @@ -25,12 +25,6 @@ describe Ohai::System, 'root_group' do @plugin = get_plugin("root_group") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :RootGroup) - Ohai::NamedPlugin.send(:remove_const, :RootGroup) - end - end - describe 'unix platform', :unix_only do before(:each) do # this is deeply intertwingled. unfortunately, the law of demeter diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb index 49e8c9c3..6c3a3def 100644 --- a/spec/unit/plugins/ruby_spec.rb +++ b/spec/unit/plugins/ruby_spec.rb @@ -31,12 +31,6 @@ describe Ohai::System, "plugin ruby" do @ruby_ohai_data_pristine = @plugin[:languages][:ruby] end - after(:all) do - if Ohai::NamedPlugin.send(:const_defined?, :Ruby) - Ohai::NamedPlugin.send(:remove_const, :Ruby) - end - end - before(:each) do @ruby_ohai_data = @ruby_ohai_data_pristine.dup end diff --git a/spec/unit/plugins/sigar/network_route_spec.rb b/spec/unit/plugins/sigar/network_route_spec.rb index c4e05253..6d71798c 100644 --- a/spec/unit/plugins/sigar/network_route_spec.rb +++ b/spec/unit/plugins/sigar/network_route_spec.rb @@ -126,12 +126,6 @@ describe Ohai::System, "Sigar network route plugin" do @plugin.run end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Network) - Ohai::NamedPlugin.send(:remove_const, :Network) - end - end - it "should set the routes" do @plugin[:network][:interfaces][:eth0].should have_key(:route) end diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb index 2e6fcaeb..4ed8ae26 100644 --- a/spec/unit/plugins/solaris2/hostname_spec.rb +++ b/spec/unit/plugins/solaris2/hostname_spec.rb @@ -26,12 +26,6 @@ describe Ohai::System, "Solaris2.X hostname plugin" do Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] ); end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Hostname) - Ohai::NamedPlugin.send(:remove_const, :Hostname) - end - end - it_should_check_from("solaris2::hostname", "hostname", "hostname", "kitteh") it "should get the fqdn value from socket getaddrinfo" do diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb index 56741236..d252441a 100644 --- a/spec/unit/plugins/solaris2/kernel_spec.rb +++ b/spec/unit/plugins/solaris2/kernel_spec.rb @@ -141,13 +141,6 @@ describe Ohai::System, "Solaris2.X kernel plugin" do @plugin.stub(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Kernel) - Ohai::NamedPlugin.send(:remove_const, :Kernel) - end - end - - it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""]) it "gives excruciating detail about kernel modules" do diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb index 20942f89..c895aa60 100644 --- a/spec/unit/plugins/solaris2/network_spec.rb +++ b/spec/unit/plugins/solaris2/network_spec.rb @@ -120,12 +120,6 @@ ROUTE_GET @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @soalris_route_get, "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Network) - Ohai::NamedPlugin.send(:remove_const, :Network) - end - end - describe "gathering IP layer address info" do before do @stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get) diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb index afa17cb1..d7ce9556 100644 --- a/spec/unit/plugins/solaris2/platform_spec.rb +++ b/spec/unit/plugins/solaris2/platform_spec.rb @@ -26,12 +26,6 @@ describe Ohai::System, "Solaris plugin platform" do @plugin.stub(:shell_out).with("/sbin/uname -X") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Platform) - Ohai::NamedPlugin.send(:remove_const, :Platform) - end - end - describe "on SmartOS" do before(:each) do @uname_x = <<-UNAME_X diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb index 8a90a731..b2b02511 100644 --- a/spec/unit/plugins/solaris2/virtualization_spec.rb +++ b/spec/unit/plugins/solaris2/virtualization_spec.rb @@ -38,12 +38,6 @@ PSRINFO_PV @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", "")) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Virtualization) - Ohai::NamedPlugin.send(:remove_const, :Virtualization) - end - end - describe "when we are checking for kvm" do before(:each) do File.should_receive(:exists?).with("/usr/sbin/psrinfo").and_return(true) diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb index f01b3e9b..4ead4478 100644 --- a/spec/unit/plugins/ssh_host_keys_spec.rb +++ b/spec/unit/plugins/ssh_host_keys_spec.rb @@ -47,12 +47,6 @@ describe Ohai::System, "ssh_host_key plugin" do IO.stub(:read).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(@ecdsa_key) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :SSHHostKey) - Ohai::NamedPlugin.send(:remove_const, :SSHHostKey) - end - end - shared_examples "loads keys" do it "reads the key and sets the dsa attribute correctly" do @plugin.run diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb index d558702c..bcd44f6b 100644 --- a/spec/unit/runner_spec.rb +++ b/spec/unit/runner_spec.rb @@ -34,12 +34,6 @@ describe Ohai::Runner, "run_plugin" do @plugin = klass.new(@ohai, "/tmp/plugins/thing.rb") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Test) - Ohai::NamedPlugin.send(:remove_const, :Test) - end - end - it "should not find dependencies" do @runner.should_receive(:fetch_providers).with([]).and_return([]) @runner.run_plugin(@plugin) @@ -75,12 +69,6 @@ describe Ohai::Runner, "run_plugin" do @plugin = klass.new(@ohai, "/tmp/plugins/thing.rb") end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Test) - Ohai::NamedPlugin.send(:remove_const, :Test) - end - end - it "should raise a NoAttributeError" do expect { @runner.run_plugin(@plugin) }.to raise_error(Ohai::NoAttributeError) end @@ -114,14 +102,6 @@ describe Ohai::Runner, "run_plugin" do @plugin1, @plugin2 = @plugins end - after(:each) do - [:Thing, :Other].each do |plugin_name| - if Ohai::NamedPlugin.send(:const_defined?, plugin_name) - Ohai::NamedPlugin.send(:remove_const, plugin_name) - end - end - end - it "should locate the provider" do @ohai.attributes[:thing] = Mash.new @ohai.attributes[:thing][:providers] = [@plugin1] @@ -167,14 +147,6 @@ describe Ohai::Runner, "run_plugin" do @plugin1, @plugin2, @plugin3 = @plugins end - after(:each) do - [:Thing, :Other].each do |plugin_name| - if Ohai::NamedPlugin.send(:const_defined?, plugin_name) - Ohai::NamedPlugin.send(:remove_const, plugin_name) - end - end - end - it "should locate each provider" do @ohai.attributes[:thing] = Mash.new @ohai.attributes[:thing][:providers] = [@plugin1, @plugin2] @@ -229,14 +201,6 @@ describe Ohai::Runner, "run_plugin" do @plugin1, @plugin2, @plugin3 = @plugins end - after(:each) do - [:One, :Two, :Three].each do |plugin_name| - if Ohai::NamedPlugin.send(:const_defined?, plugin_name) - Ohai::NamedPlugin.send(:remove_const, plugin_name) - end - end - end - it "should locate each provider" do @ohai.attributes[:one] = Mash.new @ohai.attributes[:one][:providers] = [@plugin1] @@ -287,14 +251,6 @@ describe Ohai::Runner, "run_plugin" do @plugin1, @plugin2 = @plugins end - after(:each) do - [:Thing, :Other].each do |plugin_name| - if Ohai::NamedPlugin.send(:const_defined?, plugin_name) - Ohai::NamedPlugin.send(:remove_const, plugin_name) - end - end - end - it "should raise a DependencyCycleError" do @runner.stub(:fetch_providers).with(["thing"]).and_return([@plugin1]) @runner.stub(:fetch_providers).with(["other"]).and_return([@plugin2]) @@ -339,14 +295,6 @@ describe Ohai::Runner, "run_plugin" do @runner.stub(:fetch_providers).with([]).and_return([]) end - after(:each) do - [:A, :B, :C].each do |plugin_name| - if Ohai::NamedPlugin.send(:const_defined?, plugin_name) - Ohai::NamedPlugin.send(:remove_const, plugin_name) - end - end - end - it "should not detect a cycle when B is the first provider returned" do @runner.stub(:fetch_providers).with(["B", "C"]).and_return([@pluginB, @pluginC]) Ohai::Log.should_not_receive(:error).with(/DependencyCycleError/) @@ -477,14 +425,6 @@ describe Ohai::Runner, "#get_cycle" do @plugin1, @plugin2, @plugin3 = plugins end - after(:each) do - [:One, :Two, :Three].each do |plugin_name| - if Ohai::NamedPlugin.send(:const_defined?, plugin_name) - Ohai::NamedPlugin.send(:remove_const, plugin_name) - end - end - end - it "should return the sources for the plugins in the cycle, when given an exact cycle" do cycle = [@plugin1, @plugin2] cycle_start = @plugin1 diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index 48669b6f..ee5a8a81 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -51,10 +51,6 @@ describe "Ohai::System" do loader.stub(:load_plugin).with("/tmp/plugins/empty.rb", anything()).and_return(plugin) end - after(:each) do - Ohai::NamedPlugin.send(:remove_const, :Test) - end - it "should load plugins when plugin_path has a trailing slash" do Ohai::Config[:plugin_path] = ["/tmp/plugins/"] Dir.should_receive(:[]).with("/tmp/plugins/*").and_return(["/tmp/plugins/empty.rb"]) @@ -103,12 +99,6 @@ describe "Ohai::System" do end after(:each) do - @names.each do |name| - name_sym = name.capitalize.to_sym - if Ohai::NamedPlugin.send(:const_defined?, name_sym) - Ohai::NamedPlugin.send(:remove_const, name_sym) - end - end @ohai.v6_dependency_solver.clear end @@ -141,12 +131,6 @@ describe "Ohai::System" do @ohai.stub(:collect_providers).and_return([plugin]) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Empty) - Ohai::NamedPlugin.send(:remove_const, :Empty) - end - end - describe "when a NoAttributeError is received" do it "should write an error to Ohai::Log" do @runner.stub(:run_plugin).and_raise(Ohai::NoAttributeError) @@ -184,14 +168,6 @@ describe "Ohai::System" do @ohai.stub(:collect_providers).and_return(@plugins) end - after(:each) do - @names.each do |name| - if Ohai::NamedPlugin.send(:const_defined?, name) - Ohai::NamedPlugin.send(:remove_const, name) - end - end - end - it "should run each plugin once from Ohai::System" do @plugins.each do |plugin| @runner.should_receive(:run_plugin).with(plugin, false) @@ -244,14 +220,6 @@ EOF end end - after(:each) do - @names.each do |name| - if Ohai::NamedPlugin.send(:const_defined?, name) - Ohai::NamedPlugin.send(:remove_const, name) - end - end - end - it "should run each plugin" do @ohai.run_plugins(true) @plugins.each { |plugin| plugin.has_run?.should be_true } @@ -285,14 +253,6 @@ EOF end end - after(:each) do - @names.each do |name| - if Ohai::NamedPlugin.send(:const_defined?, name) - Ohai::NamedPlugin.send(:remove_const, name) - end - end - end - it "should find all the plugins providing attributes" do a = @ohai.attributes a[:zero] = Mash.new @@ -325,13 +285,6 @@ EOF @ohai.stub(:plugin_for).with("empty").and_return(@plugin) end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Empty) - Ohai::NamedPlugin.send(:remove_const, :Empty) - end - Ohai::Config[:plugin_path] = @plugin_path - end - it "should immediately return if force is false and the plugin has already run" do @ohai.v6_dependency_solver['empty'] = @plugin @plugin.stub(:has_run?).and_return(true) @@ -405,14 +358,6 @@ EOF @ohai.attributes[:message][:providers] = [@v7plugin] end - after(:each) do - [:V6plugin, :V7plugin].each do |name| - if Ohai::NamedPlugin.send(:const_defined?, name) - Ohai::NamedPlugin.send(:remove_const, name) - end - end - end - it "should run the plugin it requires" do @ohai.require_plugin('v6plugin') @v7plugin.has_run?.should be_true @@ -462,14 +407,6 @@ EOF a[:other][:providers] = [@other] end - after(:each) do - [:V6plugin, :V7plugin, :Other].each do |name| - if Ohai::NamedPlugin.send(:const_defined?, name) - Ohai::NamedPlugin.send(:remove_const, name) - end - end - end - it "should resolve the v7 plugin dependencies" do @ohai.require_plugin('v6plugin') [@v6plugin, @v7plugin, @other].each do |plugin| @@ -501,12 +438,6 @@ EOF @klass = Ohai.v6plugin('empty') { } end - after(:each) do - if Ohai::NamedPlugin.send(:const_defined?, :Empty) - Ohai::NamedPlugin.send(:remove_const, :Empty) - end - end - it "should find a plugin with a simple name" do plugin = @klass.new(@ohai, "/tmp/plugins/empty.rb") File.stub(:join).with("/tmp/plugins", "empty.rb").and_return("/tmp/plugins/empty.rb") |