summaryrefslogtreecommitdiff
path: root/spec/unit/knife_spec.rb
diff options
context:
space:
mode:
authorSteven Danna <steve@chef.io>2015-10-22 09:31:51 +0100
committerSteven Danna <steve@chef.io>2015-10-29 14:03:22 +0000
commit5a1eb3e0cba55068aeaec03e0d2271e19a7ad4e7 (patch)
tree79e15822e47ddabe832fba95577a65eacbd15ff6 /spec/unit/knife_spec.rb
parent571891bf67667d0240edd632c36fc84cd0fc8bbe (diff)
downloadchef-5a1eb3e0cba55068aeaec03e0d2271e19a7ad4e7.tar.gz
Improve detection of ChefFS-based commands in `knife rehash`ssd/rehash-cheffs
ChefFS-based commands have a superclass (Chef::ChefFS::Knife) which defines its own inherited method that calls super. This breaks our detection of where the subcommand is defined since the file with the definition is no longer at the top of the call stack. This commit special-cases subclasses with a superclass of Chef::ChefFS::Knife to account for this. Fixes #4089
Diffstat (limited to 'spec/unit/knife_spec.rb')
-rw-r--r--spec/unit/knife_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 022256f370..9e76ec59c4 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -117,6 +117,14 @@ describe Chef::Knife do
expect(Chef::Knife.subcommands["super_awesome_command"]).to eq(SuperAwesomeCommand)
end
+ it "records the location of ChefFS-based commands correctly" do
+ class AwesomeCheffsCommand < Chef::ChefFS::Knife
+ end
+
+ Chef::Knife.load_commands
+ expect(Chef::Knife.subcommand_files["awesome_cheffs_command"]).to eq([__FILE__])
+ end
+
it "guesses a category from a given ARGV" do
Chef::Knife.subcommands_by_category["cookbook"] << :cookbook
Chef::Knife.subcommands_by_category["cookbook site"] << :cookbook_site