Added tests for highlight installed and fixed style errors

This commit is contained in:
Nath Tumlin 2017-03-13 17:52:32 -05:00
parent 250f3445b7
commit 2080c360e2
2 changed files with 15 additions and 6 deletions

View File

@ -49,15 +49,12 @@ module Hbc
else
ohai "Partial matches"
end
highlighted = partial_matches.map { |match| highlight_installed match }
puts Formatter.columns(highlighted)
puts Formatter.columns(partial_matches.map(&method(:highlight_installed)))
end
def self.highlight_installed(token)
if Cask.new(token).installed?
token = pretty_installed token
end
token
return token unless Cask.new(token).installed?
pretty_installed token
end
def self.help

View File

@ -56,4 +56,16 @@ describe Hbc::CLI::Search, :cask do
Hbc::CLI::Search.run("caskroom")
}.to output(/^No Cask found for "caskroom"\.\n/).to_stdout
end
it "doesn't highlight not installed packages" do
expect(Hbc::CLI::Search.highlight_installed "local-caffeine").to eq("local-caffeine")
end
it "highlights installed packages" do
shutup do
Hbc::CLI::Install.run("local-caffeine")
end
expect(Hbc::CLI::Search.highlight_installed "local-caffeine").to eq(pretty_installed "local-caffeine")
end
end