homebrew-cask-versions/test/cask/cli/search_test.rb
Roland Walker a335d3b06d unify and recast "Cask name" & "title" as "token"
* "Canonical App Name" becomes "Simplified App Name"
* devscript `cask_namer` renamed to `generate_cask_token`
* doc file `CASK_NAMING_REFERENCE.md` renamed to `cask_token_reference.md`
* DSL uses `"#{token}"` for interpolation instead of `"#{title}"`
* documentation text
* backend code (variables, method, class names)
* error message text
* tests
* code comments
* Cask comments
* emphasize `tags :name`
* doc: use "vendor" consistently instead of "developer"
* doc: many man page argument descriptions were incorrect
* incidental clarifications

Many backend variables similar to `cask_name` or `cask` have
been standardized to `cask_token`, `token`, etc, resolving a long-
standing ambiguity in which variables named `cask` might contain
a Cask instance or a string token.

In many places the docs could be shortened from "Cask name" to
simply "token", which is desirable because we use the term "Cask"
in too many contexts.
2014-12-01 11:00:23 -05:00

71 lines
1.8 KiB
Ruby

require 'test_helper'
describe Cask::CLI::Search do
it "lists the available Casks that match the search term" do
lambda {
Cask::CLI::Search.run('intellij')
}.must_output <<-OUTPUT.gsub(/^ */, '')
==> Partial matches
intellij-idea
intellij-idea-ce
OUTPUT
end
it "shows that there are no Casks matching a search term that did not result in anything" do
lambda {
Cask::CLI::Search.run('foo-bar-baz')
}.must_output("No Cask found for \"foo-bar-baz\".\n")
end
it "lists all available Casks with no search term" do
out, err = capture_io do
Cask::CLI::Search.run
end
out.must_match(/google-chrome/)
out.length.must_be :>, 1000
end
it "ignores hyphens in search terms" do
out, err = capture_io do
Cask::CLI::Search.run('goo-gle-chrome')
end
out.must_match(/google-chrome/)
out.length.must_be :<, 100
end
it "ignores hyphens in Cask tokens" do
out, err = capture_io do
Cask::CLI::Search.run('googlechrome')
end
out.must_match(/google-chrome/)
out.length.must_be :<, 100
end
it "accepts multiple arguments" do
out, err = capture_io do
Cask::CLI::Search.run('google chrome')
end
out.must_match(/google-chrome/)
out.length.must_be :<, 100
end
it "accepts a regexp argument" do
lambda {
Cask::CLI::Search.run('/^google-c[a-z]rome$/')
}.must_output "==> Regexp matches\ngoogle-chrome\n"
end
it "Returns both exact and partial matches" do
out, err = capture_io do
Cask::CLI::Search.run('mnemosyne')
end
out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/)
end
it "does not search the Tap name" do
out, err = capture_io do
Cask::CLI::Search.run('caskroom')
end
out.must_match(/^No Cask found for "caskroom"\.\n/)
end
end