Skip to content

Commit

Permalink
test/abstract_command_spec: rename cat to fix completions test
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Cho <michael@michaelcho.dev>
  • Loading branch information
cho-m committed Mar 21, 2024
1 parent 857838a commit ae7c558
Showing 1 changed file with 7 additions and 7 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,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

0 comments on commit ae7c558

Please sign in to comment.