summaryrefslogtreecommitdiff
path: root/spec/unit/application/knife_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-12-03 11:29:38 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-12-03 11:35:43 -0800
commit5002cbbee1135195d8dcb04f5509ab98cfb9169a (patch)
tree6ee0ea53cc51d7fb1ce11130f92a90bb98a28646 /spec/unit/application/knife_spec.rb
parenta00ed4b198ea25e14d6b7fe861b401a32352e9fa (diff)
downloadchef-5002cbbee1135195d8dcb04f5509ab98cfb9169a.tar.gz
Fix knife plugin path searching
Unreleased Chef 12.0.0 bug caught in testing where only the searching upwards from PWD to find .chef in order to get the plugin path for knife was busted. The chef_config_dir was being used before load_config was being called, so it was nil, which broke finding knife plugins. This was fixed by adding some lazy initialization of the config_loader object itself and the chef_config_dir. The reset_config_loader! is added entirely to reset the global state for unit testing. This whole class is a bit horrible and needs to have all its global state removed from it, class methods removed, class ivars and the class-variable-in-a-class-method-for-inheritance-lolwut needs to be removed. Unfortunately, that requires some delicate surgery because Chef::Knife gets used as a public API, and is beyond the scope of gettting Chef 12 shipped.
Diffstat (limited to 'spec/unit/application/knife_spec.rb')
-rw-r--r--spec/unit/application/knife_spec.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index 806a596a61..3c215eac7f 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -33,6 +33,11 @@ describe Chef::Application::Knife do
end
end
+ after(:each) do
+ # reset some really nasty global state
+ NoopKnifeCommand.reset_config_loader!
+ end
+
before(:each) do
# Prevent code from getting loaded on every test invocation.
allow(Chef::Knife).to receive(:load_commands)
@@ -109,7 +114,6 @@ describe Chef::Application::Knife do
end
expect(Chef::Config[:client_key]).to eq(full_path)
end
-
end
describe "with environment configuration" do
@@ -168,6 +172,6 @@ describe Chef::Application::Knife do
@knife.run
end
end
-
end
+
end