From 8d1fa0553026da8fc119bf82196b25dec4478f2e Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 4 Apr 2024 09:48:17 -0700 Subject: [PATCH] Restrict AbstractCommand test to commands in repo --- Library/Homebrew/test/abstract_command_spec.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/test/abstract_command_spec.rb b/Library/Homebrew/test/abstract_command_spec.rb index e3ae8add92..1e47581650 100644 --- a/Library/Homebrew/test/abstract_command_spec.rb +++ b/Library/Homebrew/test/abstract_command_spec.rb @@ -62,17 +62,14 @@ RSpec.describe Homebrew::AbstractCommand do describe "command paths" do it "match command name" do - # Ensure all commands are loaded ["cmd", "dev-cmd"].each do |dir| - Dir[File.join(__dir__, "../#{dir}", "*.rb")].each { require(_1) } - end - test_classes = ["TestCat", "Tac"] - - described_class.subclasses.each do |klass| - next if test_classes.include?(klass.name) - - dir = klass.name.start_with?("Homebrew::DevCmd") ? "dev-cmd" : "cmd" - expect(Pathname(File.join(__dir__, "../#{dir}/#{klass.command_name}.rb"))).to exist + Dir[File.join(__dir__, "../#{dir}", "*.rb")].each do |file| + filename = File.basename(file, ".rb") + require(file) + command = described_class.command(filename) + dir = command.name.start_with?("Homebrew::DevCmd") ? "dev-cmd" : "cmd" + expect(Pathname(File.join(__dir__, "../#{dir}/#{command.command_name}.rb"))).to exist + end end end end