Merge pull request #16934 from cho-m/test-shell-completion-error

test/abstract_command_spec: rename cat to fix completions test
This commit is contained in:
Douglas Eichelberger 2024-03-21 18:17:28 -07:00 committed by GitHub
commit 1a62a639b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -5,7 +5,7 @@ require "abstract_command"
RSpec.describe Homebrew::AbstractCommand do
describe "subclasses" do
before do
cat = Class.new(described_class) do
test_cat = Class.new(described_class) do
cmd_args do
description "test"
switch "--foo"
@ -13,30 +13,30 @@ RSpec.describe Homebrew::AbstractCommand do
end
def run; end
end
stub_const("Cat", cat)
stub_const("TestCat", test_cat)
end
describe "parsing args" do
it "parses valid args" do
expect { Cat.new(["--foo"]).run }.not_to raise_error
expect { TestCat.new(["--foo"]).run }.not_to raise_error
end
it "allows access to args" do
expect(Cat.new(["--bar", "baz"]).args[:bar]).to eq("baz")
expect(TestCat.new(["--bar", "baz"]).args[:bar]).to eq("baz")
end
it "raises on invalid args" do
expect { Cat.new(["--bat"]) }.to raise_error(OptionParser::InvalidOption)
expect { TestCat.new(["--bat"]) }.to raise_error(OptionParser::InvalidOption)
end
end
describe "command names" do
it "has a default command name" do
expect(Cat.command_name).to eq("cat")
expect(TestCat.command_name).to eq("test-cat")
end
it "can lookup command" do
expect(described_class.command("cat")).to be(Cat)
expect(described_class.command("test-cat")).to be(TestCat)
end
describe "when command name is overridden" do

View File

@ -1,4 +1,4 @@
# typed: strict
class Cat < Homebrew::AbstractCommand; end
class TestCat < Homebrew::AbstractCommand; end
class Tac < Homebrew::AbstractCommand; end