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

Write tests for 'brew list --version [--cask]'. #18999

Closed
wants to merge 3 commits into from
Closed
Changes from 2 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
32 changes: 30 additions & 2 deletions Library/Homebrew/test/cmd/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,47 @@
require "cmd/shared_examples/args_parse"

RSpec.describe Homebrew::Cmd::List do
let(:formulae) { %w[bar foo qux] }
let(:formulae) { %w[bar qux foo] }
let(:casks) { %w[tex git sgb] }

it_behaves_like "parseable arguments"

it "prints all installed Formulae", :integration_test do
ascherer marked this conversation as resolved.
Show resolved Hide resolved
formulae.each do |f|
(HOMEBREW_CELLAR/f/"1.0/somedir").mkpath
end
casks.each do |f|
(HOMEBREW_PREFIX/"Caskroom"/f/"42.0/somedir").mkpath
end

expect { brew "list", "--formula" }
.to output("#{formulae.join("\n")}\n").to_stdout
.to output("#{formulae.sort.join("\n")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success

expect { brew "list", "--cask" }
.to output("#{casks.sort.join("\n")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success

expect { brew "list", "--formula", "--version" }
.to output("#{formulae.sort.map { |name| "#{name} 1.0" }.join("\n")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success

# expect { brew "list", "--cask", "--version" }
# .to output("#{casks.sort.map { |name| "#{name} 42.0" }.join("\n")}\n").to_stdout
# .and not_to_output.to_stderr
# .and be_a_success

# expect { brew "list", "--version" }
# .to output(<<~OUTPUT,
# #{formulae.sort.map { |name| "#{name} 1.0" }.join("\n")}
# #{casks.sort.map { |name| "#{name} 42.0" }.join("\n")}
# OUTPUT
# ).to_stdout
# .and not_to_output.to_stderr
# .and be_a_success
ascherer marked this conversation as resolved.
Show resolved Hide resolved
end

# TODO: add a test for the shell fast-path (`brew_sh`)
Expand Down
Loading