summaryrefslogtreecommitdiff
path: root/spec/unit/knife/core/hashed_command_loader_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/knife/core/hashed_command_loader_spec.rb')
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index 0135868bf5..081f9deae5 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -46,6 +46,10 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
plugin_manifest)}
describe "#list_commands" do
+ before do
+ allow(File).to receive(:exists?).and_return(true)
+ end
+
it "lists all commands by category when no argument is given" do
expect(loader.list_commands).to eq({ "cool" => ["cool_a"], "cooler" => ["cooler_b"] })
end
@@ -53,6 +57,18 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
it "lists only commands in the given category when a category is given" do
expect(loader.list_commands("cool")).to eq({ "cool" => ["cool_a"] })
end
+
+ context "when the plugin path is invalid" do
+ before do
+ expect(File).to receive(:exists?).with("/file/for/plugin/b").and_return(false)
+ end
+
+ it "lists all commands by category when no argument is given" do
+ expect(Chef::Log).to receive(:error).with(/There are files specified in the manifest that are missing/)
+ expect(Chef::Log).to receive(:error).with("Missing files:\n\t/file/for/plugin/b")
+ expect(loader.list_commands).to eq({})
+ end
+ end
end
describe "#subcommand_files" do