From b81a522230b8166d0a5409095ab43d2cae75bbb8 Mon Sep 17 00:00:00 2001 From: Connor Mann Date: Sun, 23 May 2021 16:09:35 -0400 Subject: [PATCH] Add tests for `to_latest_kegs` --- Library/Homebrew/test/cli/named_args_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Library/Homebrew/test/cli/named_args_spec.rb b/Library/Homebrew/test/cli/named_args_spec.rb index ae560870b2..66152c4ef1 100644 --- a/Library/Homebrew/test/cli/named_args_spec.rb +++ b/Library/Homebrew/test/cli/named_args_spec.rb @@ -218,6 +218,24 @@ describe Homebrew::CLI::NamedArgs do end end + describe "#to_latest_kegs" do + before do + (HOMEBREW_CELLAR/"foo/1.0").mkpath + (HOMEBREW_CELLAR/"foo/2.0").mkpath + (HOMEBREW_CELLAR/"bar/1.0").mkpath + end + + it "resolves the latest kegs with #resolve_latest_keg" do + latest_kegs = described_class.new("foo", "bar").to_latest_kegs + expect(latest_kegs.map(&:name)).to eq ["foo", "bar"] + expect(latest_kegs.map { |k| k.version.version.to_s }).to eq ["2.0", "1.0"] + end + + it "when there are no matching kegs returns an empty array" do + expect(described_class.new.to_latest_kegs).to be_empty + end + end + describe "#to_kegs_to_casks" do before do (HOMEBREW_CELLAR/"foo/1.0").mkpath