Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/abstract_command_spec: rename cat to fix completions test #16934

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,37 +5,37 @@
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
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