aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/utils_spec.rb
diff options
context:
space:
mode:
authorDan Wendorf2017-07-08 19:33:44 -0700
committerDan Wendorf2017-09-16 10:00:06 -0700
commitacf1b278ae0c27f19e7d20a9d23c005201dc818c (patch)
tree4b43a21c708c83a116cfc2aed712fb62f8e2b312 /Library/Homebrew/test/utils_spec.rb
parent2056cd2c90109ab410118442f0aacf73f6fb198c (diff)
downloadbrew-acf1b278ae0c27f19e7d20a9d23c005201dc818c.tar.bz2
List cask full-names
`brew cask list` supports the `--full-name` flag which will include the tap name for casks not part of the core caskroom/cask tap. For example, if cask "foo-beta" is installed from the caskroom/versions cask, `brew cask list --full-name` will report the name as "caskroom/versions/foo-beta".
Diffstat (limited to 'Library/Homebrew/test/utils_spec.rb')
-rw-r--r--Library/Homebrew/test/utils_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb
index 37bd83c4f..3b5355b15 100644
--- a/Library/Homebrew/test/utils_spec.rb
+++ b/Library/Homebrew/test/utils_spec.rb
@@ -296,4 +296,33 @@ describe "globally-scoped helper methods" do
expect(ENV["PATH"]).not_to eq("/bin")
end
end
+
+ describe "#tap_and_name_comparison" do
+ describe "both strings are only names" do
+ it "alphabetizes the strings" do
+ expect(%w[a b].sort(&tap_and_name_comparison)).to eq(%w[a b])
+ expect(%w[b a].sort(&tap_and_name_comparison)).to eq(%w[a b])
+ end
+ end
+
+ describe "both strings include tap" do
+ it "alphabetizes the strings" do
+ expect(%w[a/z/z b/z/z].sort(&tap_and_name_comparison)).to eq(%w[a/z/z b/z/z])
+ expect(%w[b/z/z a/z/z].sort(&tap_and_name_comparison)).to eq(%w[a/z/z b/z/z])
+
+ expect(%w[z/a/z z/b/z].sort(&tap_and_name_comparison)).to eq(%w[z/a/z z/b/z])
+ expect(%w[z/b/z z/a/z].sort(&tap_and_name_comparison)).to eq(%w[z/a/z z/b/z])
+
+ expect(%w[z/z/a z/z/b].sort(&tap_and_name_comparison)).to eq(%w[z/z/a z/z/b])
+ expect(%w[z/z/b z/z/a].sort(&tap_and_name_comparison)).to eq(%w[z/z/a z/z/b])
+ end
+ end
+
+ describe "only one string includes tap" do
+ it "prefers the string without tap" do
+ expect(%w[a/z/z z].sort(&tap_and_name_comparison)).to eq(%w[z a/z/z])
+ expect(%w[z a/z/z].sort(&tap_and_name_comparison)).to eq(%w[z a/z/z])
+ end
+ end
+ end
end