Preseve args_parse test for new commands

This commit is contained in:
Douglas Eichelberger 2024-03-08 13:35:56 -08:00
parent 6fc99d9569
commit cda2761504
3 changed files with 15 additions and 6 deletions

View File

@ -1,10 +1,13 @@
# frozen_string_literal: true
require "cmd/list"
require "cmd/shared_examples/args_parse"
RSpec.describe Homebrew::Cmd::List do
let(:formulae) { %w[bar foo qux] }
it_behaves_like "parseable arguments"
it "prints all installed Formulae", :integration_test do
formulae.each do |f|
(HOMEBREW_CELLAR/f/"1.0/somedir").mkpath

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
RSpec.shared_examples "parseable arguments" do
RSpec.shared_examples "parseable arguments" do |argv: []|
subject(:method_name) { "#{command_name.tr("-", "_")}_args" }
let(:command_name) do |example|
@ -8,10 +8,13 @@ RSpec.shared_examples "parseable arguments" do
end
it "can parse arguments" do
require "dev-cmd/#{command_name}" unless require? "cmd/#{command_name}"
parser = Homebrew.public_send(method_name)
expect(parser).to respond_to(:parse)
if described_class
cmd = described_class.new(argv)
expect(cmd.args).to be_a Homebrew::CLI::Args
else
require "dev-cmd/#{command_name}" unless require? "cmd/#{command_name}"
parser = Homebrew.public_send(method_name)
expect(parser).to respond_to(:parse)
end
end
end

View File

@ -1,8 +1,11 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "dev-cmd/prof"
RSpec.describe Homebrew::DevCmd::Prof do
it_behaves_like "parseable arguments", argv: ["--", "help"]
describe "integration tests", :integration_test, :needs_network do
after do
FileUtils.rm_rf HOMEBREW_LIBRARY_PATH/"prof"