aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-08 13:34:26 +0100
committerMarkus Reiter2017-02-10 17:19:19 +0100
commit82e6070ca045001eab7aec0ba9b85dbca48615f8 (patch)
tree3a8911c550d9752e6c54d656dd8a34251c24e3a1
parent20b77dfdcc4332f1d21e39571e1bbc7eefc6d4dd (diff)
downloadbrew-82e6070ca045001eab7aec0ba9b85dbca48615f8.tar.bz2
Convert Search test to spec.
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/search_spec.rb61
-rw-r--r--Library/Homebrew/cask/test/cask/cli/search_test.rb59
2 files changed, 61 insertions, 59 deletions
diff --git a/Library/Homebrew/cask/spec/cask/cli/search_spec.rb b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb
new file mode 100644
index 000000000..fe669dd3e
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb
@@ -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
diff --git a/Library/Homebrew/cask/test/cask/cli/search_test.rb b/Library/Homebrew/cask/test/cask/cli/search_test.rb
deleted file mode 100644
index 6eb6badb9..000000000
--- a/Library/Homebrew/cask/test/cask/cli/search_test.rb
+++ /dev/null
@@ -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