Convert Search test to spec.

This commit is contained in:
Markus Reiter 2017-02-08 13:34:26 +01:00
parent 20b77dfdcc
commit 82e6070ca0
2 changed files with 61 additions and 59 deletions

View File

@ -0,0 +1,61 @@
require "spec_helper"
describe Hbc::CLI::Search do
it "lists the available Casks that match the search term" do
expect {
Hbc::CLI::Search.run("photoshop")
}.to output(<<-EOS.undent).to_stdout
==> Partial matches
adobe-photoshop-cc
adobe-photoshop-lightroom
EOS
end
it "shows that there are no Casks matching a search term that did not result in anything" do
expect {
Hbc::CLI::Search.run("foo-bar-baz")
}.to output("No Cask found for \"foo-bar-baz\".\n").to_stdout
end
it "lists all available Casks with no search term" do
expect {
Hbc::CLI::Search.run
}.to output(/google-chrome/).to_stdout
end
it "ignores hyphens in search terms" do
expect {
Hbc::CLI::Search.run("goo-gle-chrome")
}.to output(/google-chrome/).to_stdout
end
it "ignores hyphens in Cask tokens" do
expect {
Hbc::CLI::Search.run("googlechrome")
}.to output(/google-chrome/).to_stdout
end
it "accepts multiple arguments" do
expect {
Hbc::CLI::Search.run("google chrome")
}.to output(/google-chrome/).to_stdout
end
it "accepts a regexp argument" do
expect {
Hbc::CLI::Search.run("/^google-c[a-z]rome$/")
}.to output("==> Regexp matches\ngoogle-chrome\n").to_stdout
end
it "Returns both exact and partial matches" do
expect {
Hbc::CLI::Search.run("mnemosyne")
}.to output(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/).to_stdout
end
it "does not search the Tap name" do
expect {
Hbc::CLI::Search.run("caskroom")
}.to output(/^No Cask found for "caskroom"\.\n/).to_stdout
end
end

View File

@ -1,59 +0,0 @@
require "test_helper"
describe Hbc::CLI::Search do
it "lists the available Casks that match the search term" do
lambda {
Hbc::CLI::Search.run("photoshop")
}.must_output <<-EOS.undent
==> Partial matches
adobe-photoshop-cc
adobe-photoshop-lightroom
EOS
end
it "shows that there are no Casks matching a search term that did not result in anything" do
lambda {
Hbc::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 = capture_io { Hbc::CLI::Search.run }[0]
out.must_match(/google-chrome/)
out.length.must_be :>, 1000
end
it "ignores hyphens in search terms" do
out = capture_io { Hbc::CLI::Search.run("goo-gle-chrome") }[0]
out.must_match(/google-chrome/)
out.length.must_be :<, 100
end
it "ignores hyphens in Cask tokens" do
out = capture_io { Hbc::CLI::Search.run("googlechrome") }[0]
out.must_match(/google-chrome/)
out.length.must_be :<, 100
end
it "accepts multiple arguments" do
out = capture_io { Hbc::CLI::Search.run("google chrome") }[0]
out.must_match(/google-chrome/)
out.length.must_be :<, 100
end
it "accepts a regexp argument" do
lambda {
Hbc::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 = capture_io { Hbc::CLI::Search.run("mnemosyne") }[0]
out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/)
end
it "does not search the Tap name" do
out = capture_io { Hbc::CLI::Search.run("caskroom") }[0]
out.must_match(/^No Cask found for "caskroom"\.\n/)
end
end