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

196 lines
5.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-05-19 14:58:55 +05:30
require "utils"
2017-10-03 10:49:58 +02:00
RSpec.describe Cask::Info, :cask do
2024-12-12 00:01:30 -08:00
let(:args) { instance_double(Homebrew::Cmd::Info::Args) }
before do
# Prevent unnecessary network requests in `Utils::Analytics.cask_output`
ENV["HOMEBREW_NO_ANALYTICS"] = "1"
end
2016-08-18 22:11:42 +03:00
it "displays some nice info about the specified Cask" do
expect do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("local-transmission"), args:)
end.to output(<<~EOS).to_stdout
2022-08-15 07:52:32 -07:00
==> local-transmission: 2.61
https://transmissionbt.com/
2016-08-18 22:11:42 +03:00
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/l/local-transmission.rb
2016-08-18 22:11:42 +03:00
==> Name
Transmission
==> Description
BitTorrent client
2016-08-18 22:11:42 +03:00
==> Artifacts
Transmission.app (App)
2016-08-18 22:11:42 +03:00
EOS
end
2024-08-02 20:53:50 +02:00
it "prints cask dependencies if the Cask has any" do
expect do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("with-depends-on-cask-multiple"), args:)
2024-08-02 20:53:50 +02:00
end.to output(<<~EOS).to_stdout
==> with-depends-on-cask-multiple: 1.2.3
https://brew.sh/with-depends-on-cask-multiple
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/with-depends-on-cask-multiple.rb
==> Name
None
==> Description
None
==> Dependencies
local-caffeine (cask), local-transmission (cask)
==> Artifacts
Caffeine.app (App)
EOS
end
it "prints cask and formulas dependencies if the Cask has both" do
expect do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("with-depends-on-everything"), args:)
2024-08-02 20:53:50 +02:00
end.to output(<<~EOS).to_stdout
==> with-depends-on-everything: 1.2.3
https://brew.sh/with-depends-on-everything
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/with-depends-on-everything.rb
==> Name
None
==> Description
None
==> Dependencies
unar, local-caffeine (cask), with-depends-on-cask (cask)
==> Artifacts
Caffeine.app (App)
EOS
end
2018-09-20 09:07:56 +01:00
it "prints auto_updates if the Cask has `auto_updates true`" do
expect do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("with-auto-updates"), args:)
end.to output(<<~EOS).to_stdout
2022-08-15 07:52:32 -07:00
==> with-auto-updates: 1.0 (auto_updates)
https://brew.sh/autoupdates
2018-06-15 16:16:55 +10:00
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/with-auto-updates.rb
2018-06-15 16:16:55 +10:00
==> Name
AutoUpdates
==> Description
None
2018-06-15 16:16:55 +10:00
==> Artifacts
AutoUpdates.app (App)
EOS
end
it "prints caveats if the Cask provided one" do
expect do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("with-caveats"), args:)
end.to output(<<~EOS).to_stdout
2022-08-15 07:52:32 -07:00
==> with-caveats: 1.2.3
https://brew.sh/
2016-08-18 22:11:42 +03:00
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/with-caveats.rb
2016-08-18 22:11:42 +03:00
==> Name
None
==> Description
None
2016-08-18 22:11:42 +03:00
==> 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, e.g. (for Bash shell):
2016-08-18 22:11:42 +03:00
export PATH=/custom/path/bin:"$PATH"
EOS
end
it 'does not print "Caveats" section divider if the caveats block has no output' do
expect do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("with-conditional-caveats"), args:)
end.to output(<<~EOS).to_stdout
2022-08-15 07:52:32 -07:00
==> with-conditional-caveats: 1.2.3
https://brew.sh/
2016-08-18 22:11:42 +03:00
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/with-conditional-caveats.rb
2016-08-18 22:11:42 +03:00
==> Name
None
==> Description
None
2016-08-18 22:11:42 +03:00
==> 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 do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("with-languages"), args:)
end.to output(<<~EOS).to_stdout
2022-08-15 07:52:32 -07:00
==> with-languages: 1.2.3
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/with-languages.rb
==> Name
None
==> Description
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 do
2024-12-12 00:01:30 -08:00
described_class.info(Cask::CaskLoader.load("without-languages"), args:)
end.to output(<<~EOS).to_stdout
2022-08-15 07:52:32 -07:00
==> without-languages: 1.2.3
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/without-languages.rb
==> Name
None
==> Description
None
==> Artifacts
Caffeine.app (App)
EOS
end
2024-07-05 10:47:05 -04:00
2024-07-15 13:55:23 -04:00
it "prints install information for an installed Cask" do
mktmpdir do |caskroom|
FileUtils.mkdir caskroom/"2.61"
2024-07-05 10:47:05 -04:00
2024-07-15 13:55:23 -04:00
cask = Cask::CaskLoader.load("local-transmission")
time = 1_720_189_863
tab = Cask::Tab.new(loaded_from_api: true, tabfile: TEST_FIXTURE_DIR/"cask_receipt.json", time:)
expect(cask).to receive(:installed?).and_return(true)
expect(cask).to receive(:caskroom_path).and_return(caskroom)
expect(cask).to receive(:installed_version).and_return("2.61")
expect(Cask::Tab).to receive(:for_cask).with(cask).and_return(tab)
2024-07-15 13:31:39 -04:00
2024-07-15 13:55:23 -04:00
expect do
2024-12-12 00:01:30 -08:00
described_class.info(cask, args:)
2024-07-15 13:55:23 -04:00
end.to output(<<~EOS).to_stdout
==> local-transmission: 2.61
https://transmissionbt.com/
Installed
#{caskroom}/2.61 (0B)
Installed using the formulae.brew.sh API on #{Time.at(time).strftime("%Y-%m-%d at %H:%M:%S")}
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/l/local-transmission.rb
==> Name
Transmission
==> Description
BitTorrent client
==> Artifacts
Transmission.app (App)
EOS
2024-07-15 13:31:39 -04:00
end
2024-07-05 10:47:05 -04:00
end
2016-08-18 22:11:42 +03:00
end