diff options
author | Tim Smith <tsmith@chef.io> | 2017-04-05 09:57:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 09:57:04 -0700 |
commit | daeb73c1089d8b611bc5fde3bfddddad28f304eb (patch) | |
tree | 63ae8c30e576a08d95ad3d2fd92af14c451ae377 | |
parent | fc6dcef49c25dbba99c1e05ce001e1b947698570 (diff) | |
parent | a7ef9a97a418566bafa2b4600191d413cac9b18e (diff) | |
download | ohai-daeb73c1089d8b611bc5fde3bfddddad28f304eb.tar.gz |
Merge pull request #984 from chef/tm/additional_load_additional
Load all the plugin paths for dep resolution
-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 |