Skip to content

Commit

Permalink
Merge pull request #16934 from cho-m/test-shell-completion-error
Browse files Browse the repository at this point in the history
test/abstract_command_spec: rename cat to fix completions test
  • Loading branch information
dduugg committed Mar 22, 2024
2 parents af8880e + 57b7f39 commit 1a62a63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Library/Homebrew/test/abstract_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@
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"
flag "--bar="
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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/abstract_command_spec.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict

class Cat < Homebrew::AbstractCommand; end
class TestCat < Homebrew::AbstractCommand; end
class Tac < Homebrew::AbstractCommand; end

0 comments on commit 1a62a63

Please sign in to comment.