diff options
author | John Keiser <jkeiser@opscode.com> | 2013-09-16 22:21:18 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-09-16 22:21:18 -0700 |
commit | a71ec74507ea8f8f5e39fe99e91cb22f6b3d5f00 (patch) | |
tree | 7afcd90f97de23e74d6c2725751efe82e0737daa | |
parent | 65d41edd4108622b836917580ab515b978c76562 (diff) | |
download | ohai-a71ec74507ea8f8f5e39fe99e91cb22f6b3d5f00.tar.gz |
Use mixlib-config 2.0 and reset config before each test
-rw-r--r-- | lib/ohai/config.rb | 10 | ||||
-rw-r--r-- | ohai.gemspec | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 | ||||
-rw-r--r-- | spec/unit/system_spec.rb | 17 |
4 files changed, 11 insertions, 22 deletions
diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb index 156b300e..cad7de3b 100644 --- a/lib/ohai/config.rb +++ b/lib/ohai/config.rb @@ -34,10 +34,10 @@ module Ohai end - log_level :info - log_location STDOUT - plugin_path [ File.expand_path(File.join(File.dirname(__FILE__), 'plugins'))] - disabled_plugins [] - hints_path [ platform_specific_path('/etc/chef/ohai/hints') ] + default :log_level, :info + default :log_location, STDOUT + default :plugin_path, [ File.expand_path(File.join(File.dirname(__FILE__), 'plugins'))] + default :disabled_plugins, [] + default(:hints_path) { [ platform_specific_path('/etc/chef/ohai/hints') ] } end end diff --git a/ohai.gemspec b/ohai.gemspec index 945f866e..5f0db9e4 100644 --- a/ohai.gemspec +++ b/ohai.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |s| s.add_dependency "yajl-ruby" s.add_dependency "mixlib-cli" - s.add_dependency "mixlib-config" + s.add_dependency "mixlib-config", ">= 2.0.0.rc.4" s.add_dependency "mixlib-log" s.add_dependency "mixlib-shellout" s.add_dependency "ipaddress" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 51786d15..89017881 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -91,4 +91,8 @@ RSpec.configure do |config| config.filter_run_excluding :ruby_19_only => true unless ruby_19? config.filter_run_excluding :requires_root => true unless ENV['USER'] == 'root' config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root' + + config.before :each do + Ohai::Config.reset + end end diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index b5e6a5bf..c29ca2b2 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -40,7 +40,6 @@ describe "Ohai::System" do describe "#load_plugins" do before(:each) do - @plugin_path = Ohai::Config[:plugin_path] Ohai::OS.stub(:collect_os).and_return("ubuntu") loader = double('@loader') @@ -52,10 +51,6 @@ describe "Ohai::System" do loader.stub(:load_plugin).with("/tmp/plugins/empty.rb").and_return(plugin) end - after(:each) do - Ohai::Config[:plugin_path] = @plugin_path - 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"]) @@ -262,15 +257,10 @@ describe "Ohai::System" do end context "when a plugin is disabled" do - before(:all) do - @disabled_plugins = Ohai::Config[:disabled_plugins] + before(:each) do Ohai::Config[:disabled_plugins] = ["empty"] end - after(:all) do - Ohai::Config[:disabled_plugins] = @disabled_plugins - end - it "should not run the plugin" do Ohai::Log.should_receive(:debug).with(/Skipping disabled plugin/) @ohai.should_not_receive(:plugin_for).with("empty") @@ -392,7 +382,6 @@ EOF describe "#plugin_for" do before(:each) do - @plugin_path = Ohai::Config[:plugin_path] Ohai::Config[:plugin_path] = ["/tmp/plugins"] @loader = double('@loader') @@ -402,10 +391,6 @@ EOF @klass = Ohai.v6plugin { } end - after(:each) do - Ohai::Config[:plugin_path] = @plugin_path - 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") |