Skip to content

Commit

Permalink
Account for directory being a string via client.rb
Browse files Browse the repository at this point in the history
Make sure it's an array before we .each it and add a spec that passes it as a string

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Jul 10, 2018
1 parent 0c3e7c0 commit 71800b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/ohai/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def configure_ohai

# add any additional CLI passed directories to the plugin path excluding duplicates
unless Ohai.config[:directory].nil?
Ohai.config[:directory].each do |dir|
# make sure the directory config is an array since it could be a string set in client.rb
Array(Ohai.config[:directory]).each do |dir|
next if Ohai.config[:plugin_path].include?(dir)
Ohai.config[:plugin_path] << dir
end
Expand Down
12 changes: 11 additions & 1 deletion spec/unit/system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@
end
end

context "when a single directory is configured as a string" do
let(:directory) { "/some/fantastic/plugins" }

it "adds directory to plugin_path" do
Ohai.config[:directory] = directory
Ohai::System.new({ invoked_from_cli: true })
expect(Ohai.config[:plugin_path]).to include("/some/fantastic/plugins")
end
end

context "when multiple directories are configured" do
let(:directory) { ["/some/fantastic/plugins", "/some/other/plugins"] }

it "adds directory to plugin_path" do
it "adds directories to plugin_path" do
Ohai.config[:directory] = directory
Ohai::System.new({ invoked_from_cli: true })
expect(Ohai.config[:plugin_path]).to include("/some/fantastic/plugins")
Expand Down

0 comments on commit 71800b5

Please sign in to comment.