From 82e6070ca045001eab7aec0ba9b85dbca48615f8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:34:26 +0100 Subject: [PATCH] Convert Search test to spec. --- .../cask/spec/cask/cli/search_spec.rb | 61 +++++++++++++++++++ .../cask/test/cask/cli/search_test.rb | 59 ------------------ 2 files changed, 61 insertions(+), 59 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/search_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/search_test.rb 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 0000000000..fe669dd3e2 --- /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 6eb6badb96..0000000000 --- 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