Unified tests formatting for multiline output matching

This commit is contained in:
Alexey Alekhin 2017-08-26 02:01:08 +02:00
parent 3b7e0d8dbe
commit 68c837f041

View File

@ -36,7 +36,9 @@ describe Hbc::CLI::Search, :cask do
it "shows that there are no Casks matching a search term that did not result in anything" do it "shows that there are no Casks matching a search term that did not result in anything" do
expect { expect {
Hbc::CLI::Search.run("foo-bar-baz") Hbc::CLI::Search.run("foo-bar-baz")
}.to output("No Cask found for \"foo-bar-baz\".\n").to_stdout.as_tty }.to output(<<-EOS.undent).to_stdout.as_tty
No Cask found for "foo-bar-baz".
EOS
end end
it "lists all Casks available offline with no search term" do it "lists all Casks available offline with no search term" do
@ -68,19 +70,29 @@ describe Hbc::CLI::Search, :cask do
it "accepts a regexp argument" do it "accepts a regexp argument" do
expect { expect {
Hbc::CLI::Search.run("/^local-c[a-z]ffeine$/") Hbc::CLI::Search.run("/^local-c[a-z]ffeine$/")
}.to output("==> Regexp Matches\nlocal-caffeine\n").to_stdout.as_tty }.to output(<<-EOS.undent).to_stdout.as_tty
==> Regexp Matches
local-caffeine
EOS
end end
it "Returns both exact and partial matches" do it "returns both exact and partial matches" do
expect { expect {
Hbc::CLI::Search.run("test-opera") Hbc::CLI::Search.run("test-opera")
}.to output(/^==> Exact Match\ntest-opera\n==> Partial Matches\ntest-opera-mail/).to_stdout.as_tty }.to output(<<-EOS.undent).to_stdout.as_tty
==> Exact Match
test-opera
==> Partial Matches
test-opera-mail
EOS
end end
it "does not search the Tap name" do it "does not search the Tap name" do
expect { expect {
Hbc::CLI::Search.run("caskroom") Hbc::CLI::Search.run("caskroom")
}.to output(/^No Cask found for "caskroom"\.\n/).to_stdout.as_tty }.to output(<<-EOS.undent).to_stdout.as_tty
No Cask found for "caskroom".
EOS
end end
it "doesn't highlight packages that aren't installed" do it "doesn't highlight packages that aren't installed" do