parser: add some more tests

This commit is contained in:
Rylan Polster 2021-01-14 20:45:26 -05:00
parent 74c1010256
commit 4710be2fb3

View File

@ -397,6 +397,13 @@ describe Homebrew::CLI::Parser do
expect { parser.parse([]) }.to raise_error(Homebrew::CLI::MinNamedArgumentsError) expect { parser.parse([]) }.to raise_error(Homebrew::CLI::MinNamedArgumentsError)
end end
it "treats a symbol as a single argument of the specified type" do
formula_parser = described_class.new do
named :formula
end
expect { formula_parser.parse([]) }.to raise_error(UsageError, /this command requires a formula argument/)
end
it "doesn't allow more than the specified number of arguments" do it "doesn't allow more than the specified number of arguments" do
expect { parser.parse(["foo", "bar"]) }.to raise_error(Homebrew::CLI::MaxNamedArgumentsError) expect { parser.parse(["foo", "bar"]) }.to raise_error(Homebrew::CLI::MaxNamedArgumentsError)
end end