brew/Library/Homebrew/test/cask/cli/info_spec.rb

141 lines
3.9 KiB
Ruby
Raw Normal View History

2017-03-05 19:26:56 +01:00
describe Hbc::CLI::Info, :cask do
2016-08-18 22:11:42 +03:00
it "displays some nice info about the specified Cask" do
2017-02-08 12:19:51 +01:00
expect {
2016-08-18 22:11:42 +03:00
Hbc::CLI::Info.run("local-caffeine")
2017-02-08 12:19:51 +01:00
}.to output(<<-EOS.undent).to_stdout
2016-08-18 22:11:42 +03:00
local-caffeine: 1.2.3
http://example.com/local-caffeine
Not installed
2017-02-08 12:19:51 +01:00
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb
2016-08-18 22:11:42 +03:00
==> Name
None
==> Artifacts
Caffeine.app (App)
2016-08-18 22:11:42 +03:00
EOS
end
describe "given multiple Casks" do
2017-02-08 12:19:51 +01:00
let(:expected_output) {
<<-EOS.undent
2016-08-18 22:11:42 +03:00
local-caffeine: 1.2.3
http://example.com/local-caffeine
Not installed
2017-02-08 12:19:51 +01:00
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb
2016-08-18 22:11:42 +03:00
==> Name
None
==> Artifacts
Caffeine.app (App)
2016-08-18 22:11:42 +03:00
local-transmission: 2.61
http://example.com/local-transmission
Not installed
2017-02-08 12:19:51 +01:00
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-transmission.rb
2016-08-18 22:11:42 +03:00
==> Name
None
==> Artifacts
Transmission.app (App)
2016-08-18 22:11:42 +03:00
EOS
2017-02-08 12:19:51 +01:00
}
2016-08-18 22:11:42 +03:00
it "displays the info" do
2017-02-08 12:19:51 +01:00
expect {
2016-08-18 22:11:42 +03:00
Hbc::CLI::Info.run("local-caffeine", "local-transmission")
2017-02-08 12:19:51 +01:00
}.to output(expected_output).to_stdout
2016-08-18 22:11:42 +03:00
end
it "throws away stray options" do
2017-02-08 12:19:51 +01:00
expect {
2016-08-18 22:11:42 +03:00
Hbc::CLI::Info.run("--notavalidoption", "local-caffeine", "local-transmission")
2017-05-21 02:32:46 +02:00
}.to raise_error(/invalid option/)
2016-08-18 22:11:42 +03:00
end
end
it "should print caveats if the Cask provided one" do
2017-02-08 12:19:51 +01:00
expect {
2016-08-18 22:11:42 +03:00
Hbc::CLI::Info.run("with-caveats")
2017-02-08 12:19:51 +01:00
}.to output(<<-EOS.undent).to_stdout
2016-08-18 22:11:42 +03:00
with-caveats: 1.2.3
http://example.com/local-caffeine
Not installed
2017-02-08 12:19:51 +01:00
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-caveats.rb
2016-08-18 22:11:42 +03:00
==> Name
None
==> Artifacts
Caffeine.app (App)
2016-08-18 22:11:42 +03:00
==> Caveats
Here are some things you might want to know.
Cask token: with-caveats
Custom text via puts followed by DSL-generated text:
To use with-caveats, you may need to add the /custom/path/bin directory
to your PATH environment variable, eg (for bash shell):
export PATH=/custom/path/bin:"$PATH"
EOS
end
it 'should not print "Caveats" section divider if the caveats block has no output' do
2017-02-08 12:19:51 +01:00
expect {
2016-08-18 22:11:42 +03:00
Hbc::CLI::Info.run("with-conditional-caveats")
2017-02-08 12:19:51 +01:00
}.to output(<<-EOS.undent).to_stdout
2016-08-18 22:11:42 +03:00
with-conditional-caveats: 1.2.3
http://example.com/local-caffeine
Not installed
2017-02-08 12:19:51 +01:00
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-caveats.rb
2016-08-18 22:11:42 +03:00
==> Name
None
==> Artifacts
Caffeine.app (App)
2016-08-18 22:11:42 +03:00
EOS
end
2017-10-02 11:34:50 -07:00
it "prints languages specified in the Cask" do
expect {
Hbc::CLI::Info.run("with-languages")
}.to output(<<-EOS.undent).to_stdout
with-languages: 1.2.3
http://example.com/local-caffeine
Not installed
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-languages.rb
==> Name
None
==> Languages
zh, en-US
==> Artifacts
Caffeine.app (App)
EOS
end
2017-10-02 11:34:50 -07:00
it 'does not print "Languages" section divider if the languages block has no output' do
expect {
2017-10-02 11:34:50 -07:00
Hbc::CLI::Info.run("without-languages")
}.to output(<<-EOS.undent).to_stdout
2017-10-02 11:34:50 -07:00
without-languages: 1.2.3
http://example.com/local-caffeine
Not installed
2017-10-02 11:34:50 -07:00
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/without-languages.rb
==> Name
None
==> Artifacts
Caffeine.app (App)
EOS
end
2016-08-18 22:11:42 +03:00
describe "when no Cask is specified" do
it "raises an exception" do
2017-02-08 12:19:51 +01:00
expect {
2016-08-18 22:11:42 +03:00
Hbc::CLI::Info.run
2017-02-08 12:19:51 +01:00
}.to raise_error(Hbc::CaskUnspecifiedError)
2016-08-18 22:11:42 +03:00
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
2017-02-08 12:19:51 +01:00
expect {
2016-08-18 22:11:42 +03:00
Hbc::CLI::Info.run("--notavalidoption")
2017-05-21 02:32:46 +02:00
}.to raise_error(/invalid option/)
2016-08-18 22:11:42 +03:00
end
end
end