diff options
author | Thom May <thom@chef.io> | 2017-04-05 09:57:11 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2017-04-05 09:58:08 +0100 |
commit | a7ef9a97a418566bafa2b4600191d413cac9b18e (patch) | |
tree | 9822de0f02ef6be8cc3a90632e0a9492498fc375 | |
parent | d456abf400268d3087f2c6aa711b967d70dd9ff3 (diff) | |
download | ohai-a7ef9a97a418566bafa2b4600191d413cac9b18e.tar.gz |
Load all the plugin paths for dep resolutiontm/additional_load_additional
Signed-off-by: Thom May <thom@chef.io>
-rw-r--r-- | lib/ohai/loader.rb | 1 | ||||
-rw-r--r-- | spec/unit/loader_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/system_spec.rb | 28 |
3 files changed, 16 insertions, 15 deletions
diff --git a/lib/ohai/loader.rb b/lib/ohai/loader.rb index a7104652..7dff8e7e 100644 --- a/lib/ohai/loader.rb +++ b/lib/ohai/loader.rb @@ -86,6 +86,7 @@ module Ohai end def load_additional(from) + from = [ Ohai.config[:plugin_path], from].flatten plugin_files_by_dir(from).collect do |plugin_file| Ohai::Log.debug "Loading additional plugin: #{plugin_file}" plugin = load_plugin_class(plugin_file.path, plugin_file.plugin_root) diff --git a/spec/unit/loader_spec.rb b/spec/unit/loader_spec.rb index 126e777a..8331ae65 100644 --- a/spec/unit/loader_spec.rb +++ b/spec/unit/loader_spec.rb @@ -111,7 +111,7 @@ EOF describe "#load_additional" do it "adds the plugins to the map" do loader.load_additional(@plugins_directory) - expect(provides_map.map.keys).to eql(%w{alpha beta}) + expect(provides_map.map.keys).to include("alpha") end it "returns a set of plugins" do diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index 4efe4725..b212ea0b 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -713,46 +713,46 @@ EOF describe "when loading a specific plugin path" do when_plugins_directory "contains v7 plugins" do - with_plugin("my_cookbook/languages.rb", <<-E) - Ohai.plugin(:Languages) do - provides 'languages' + with_plugin("my_cookbook/canteloupe.rb", <<-E) + Ohai.plugin(:Canteloupe) do + provides 'canteloupe' collect_data do - languages Mash.new + canteloupe Mash.new end end E with_plugin("english/english.rb", <<-E) Ohai.plugin(:English) do - provides 'languages/english' + provides 'canteloupe/english' - depends 'languages' + depends 'canteloupe' collect_data do - languages[:english] = Mash.new - languages[:english][:version] = 2014 + canteloupe[:english] = Mash.new + canteloupe[:english][:version] = 2014 end end E with_plugin("french/french.rb", <<-E) Ohai.plugin(:French) do - provides 'languages/french' + provides 'canteloupe/french' - depends 'languages' + depends 'canteloupe' collect_data do - languages[:french] = Mash.new - languages[:french][:version] = 2012 + canteloupe[:french] = Mash.new + canteloupe[:french][:version] = 2012 end end E it "should run all the plugins" do ohai.run_additional_plugins(@plugins_directory) - expect(ohai.data[:languages][:english][:version]).to eq(2014) - expect(ohai.data[:languages][:french][:version]).to eq(2012) + expect(ohai.data[:canteloupe][:english][:version]).to eq(2014) + expect(ohai.data[:canteloupe][:french][:version]).to eq(2012) end end end |