2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-08-09 01:34:07 +02:00
|
|
|
require "cask/audit"
|
|
|
|
|
2018-09-06 08:29:14 +02:00
|
|
|
describe Cask::Audit, :cask do
|
2017-03-05 03:46:13 +01:00
|
|
|
def include_msg?(messages, msg)
|
|
|
|
if msg.is_a?(Regexp)
|
|
|
|
Array(messages).any? { |m| m =~ msg }
|
|
|
|
else
|
|
|
|
Array(messages).include?(msg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
matcher :pass do
|
|
|
|
match do |audit|
|
|
|
|
!audit.errors? && !audit.warnings?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
matcher :fail_with do |error_msg|
|
|
|
|
match do |audit|
|
|
|
|
include_msg?(audit.errors, error_msg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
matcher :warn_with do |warning_msg|
|
|
|
|
match do |audit|
|
|
|
|
include_msg?(audit.warnings, warning_msg)
|
|
|
|
end
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2018-09-06 08:29:14 +02:00
|
|
|
let(:cask) { instance_double(Cask::Cask) }
|
2020-09-04 05:29:56 +02:00
|
|
|
let(:new_cask) { nil }
|
|
|
|
let(:online) { nil }
|
|
|
|
let(:strict) { nil }
|
|
|
|
let(:token_conflicts) { nil }
|
2016-08-18 22:11:42 +03:00
|
|
|
let(:audit) {
|
2020-09-04 05:29:56 +02:00
|
|
|
described_class.new(cask, online: online,
|
|
|
|
|
2020-08-10 19:34:38 +02:00
|
|
|
strict: strict,
|
2020-09-04 05:29:56 +02:00
|
|
|
new_cask: new_cask,
|
|
|
|
token_conflicts: token_conflicts)
|
2016-08-18 22:11:42 +03:00
|
|
|
}
|
|
|
|
|
2020-09-04 05:29:56 +02:00
|
|
|
describe "#new" do
|
|
|
|
context "when `new_cask` is specified" do
|
|
|
|
let(:new_cask) { true }
|
|
|
|
|
|
|
|
it "implies `online`" do
|
|
|
|
expect(audit).to be_online
|
|
|
|
end
|
|
|
|
|
|
|
|
it "implies `strict`" do
|
|
|
|
expect(audit).to be_strict
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when `online` is specified" do
|
|
|
|
let(:online) { true }
|
|
|
|
|
|
|
|
it "implies `appcast`" do
|
|
|
|
expect(audit.appcast?).to be true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "implies `download`" do
|
|
|
|
expect(audit.download).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when `strict` is specified" do
|
|
|
|
let(:strict) { true }
|
|
|
|
|
|
|
|
it "implies `token_conflicts`" do
|
|
|
|
expect(audit.token_conflicts?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-18 22:11:42 +03:00
|
|
|
describe "#result" do
|
|
|
|
subject { audit.result }
|
|
|
|
|
|
|
|
context "when there are errors" do
|
|
|
|
before do
|
|
|
|
audit.add_error "bad"
|
|
|
|
end
|
|
|
|
|
2016-10-14 20:03:34 +02:00
|
|
|
it { is_expected.to match(/failed/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when there are warnings" do
|
|
|
|
before do
|
|
|
|
audit.add_warning "eh"
|
|
|
|
end
|
|
|
|
|
2016-10-14 20:03:34 +02:00
|
|
|
it { is_expected.to match(/warning/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when there are errors and warnings" do
|
|
|
|
before do
|
|
|
|
audit.add_error "bad"
|
|
|
|
audit.add_warning "eh"
|
|
|
|
end
|
|
|
|
|
2016-10-14 20:03:34 +02:00
|
|
|
it { is_expected.to match(/failed/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when there are no errors or warnings" do
|
2016-10-14 20:03:34 +02:00
|
|
|
it { is_expected.to match(/passed/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#run!" do
|
|
|
|
subject { audit.run! }
|
|
|
|
|
2020-06-04 23:11:51 +02:00
|
|
|
def tmp_cask(name, text)
|
|
|
|
path = Pathname.new "#{dir}/#{name}.rb"
|
|
|
|
path.open("w") do |f|
|
|
|
|
f.write text
|
|
|
|
end
|
|
|
|
|
|
|
|
Cask::CaskLoader.load(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:dir) { mktmpdir }
|
2018-09-06 08:29:14 +02:00
|
|
|
let(:cask) { Cask::CaskLoader.load(cask_token) }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-08-18 22:11:42 +03:00
|
|
|
describe "required stanzas" do
|
2016-10-06 21:27:44 +08:00
|
|
|
%w[version sha256 url name homepage].each do |stanza|
|
2016-08-18 22:11:42 +03:00
|
|
|
context "when missing #{stanza}" do
|
|
|
|
let(:cask_token) { "missing-#{stanza}" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-10-14 20:03:34 +02:00
|
|
|
it { is_expected.to fail_with(/#{stanza} stanza is required/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
2018-03-25 15:30:16 +10:00
|
|
|
end
|
|
|
|
|
2020-06-04 23:11:51 +02:00
|
|
|
describe "token validation" do
|
|
|
|
let(:strict) { true }
|
|
|
|
let(:cask) do
|
|
|
|
tmp_cask cask_token.to_s, <<~RUBY
|
|
|
|
cask '#{cask_token}' do
|
|
|
|
version '1.0'
|
|
|
|
sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a'
|
|
|
|
url "https://brew.sh/"
|
|
|
|
name 'Audit'
|
|
|
|
homepage 'https://brew.sh/'
|
|
|
|
app 'Audit.app'
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token is not lowercase" do
|
|
|
|
let(:cask_token) { "Upper-Case" }
|
|
|
|
|
|
|
|
it "warns about lowercase" do
|
|
|
|
expect(subject).to warn_with(/token is not lowercase/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token is not ascii" do
|
|
|
|
let(:cask_token) { "ascii⌘" }
|
|
|
|
|
|
|
|
it "warns about ascii" do
|
|
|
|
expect(subject).to warn_with(/contains non-ascii characters/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token has +" do
|
|
|
|
let(:cask_token) { "app++" }
|
|
|
|
|
|
|
|
it "warns about +" do
|
|
|
|
expect(subject).to warn_with(/\+ should be replaced by -plus-/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token has @" do
|
|
|
|
let(:cask_token) { "app@stuff" }
|
|
|
|
|
|
|
|
it "warns about +" do
|
|
|
|
expect(subject).to warn_with(/@ should be replaced by -at-/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token has whitespace" do
|
|
|
|
let(:cask_token) { "app stuff" }
|
|
|
|
|
|
|
|
it "warns about whitespace" do
|
|
|
|
expect(subject).to warn_with(/whitespace should be replaced by hyphens/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token has underscores" do
|
|
|
|
let(:cask_token) { "app_stuff" }
|
|
|
|
|
|
|
|
it "warns about underscores" do
|
|
|
|
expect(subject).to warn_with(/underscores should be replaced by hyphens/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token has non-alphanumeric characters" do
|
|
|
|
let(:cask_token) { "app(stuff)" }
|
|
|
|
|
|
|
|
it "warns about non-alphanumeric characters" do
|
|
|
|
expect(subject).to warn_with(/should only contain alphanumeric characters and hyphens/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token has double hyphens" do
|
|
|
|
let(:cask_token) { "app--stuff" }
|
|
|
|
|
|
|
|
it "warns about double hyphens" do
|
|
|
|
expect(subject).to warn_with(/should not contain double hyphens/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token has trailing hyphens" do
|
|
|
|
let(:cask_token) { "app-" }
|
|
|
|
|
|
|
|
it "warns about trailing hyphens" do
|
|
|
|
expect(subject).to warn_with(/should not have leading or trailing hyphens/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "token bad words" do
|
|
|
|
let(:strict) { true }
|
|
|
|
let(:cask) do
|
|
|
|
tmp_cask cask_token.to_s, <<~RUBY
|
|
|
|
cask '#{cask_token}' do
|
|
|
|
version '1.0'
|
|
|
|
sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a'
|
|
|
|
url "https://brew.sh/"
|
|
|
|
name 'Audit'
|
|
|
|
homepage 'https://brew.sh/'
|
|
|
|
app 'Audit.app'
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token contains .app" do
|
|
|
|
let(:cask_token) { "token.app" }
|
|
|
|
|
|
|
|
it "warns about .app" do
|
|
|
|
expect(subject).to warn_with(/token contains .app/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-11 21:22:41 +02:00
|
|
|
context "when cask token contains version designation" do
|
2020-06-04 23:11:51 +02:00
|
|
|
let(:cask_token) { "token-beta" }
|
|
|
|
|
2020-08-11 21:22:41 +02:00
|
|
|
it "warns about version in token if the cask is from an official tap" do
|
|
|
|
allow(cask).to receive(:tap).and_return(Tap.fetch("homebrew/cask"))
|
|
|
|
|
|
|
|
expect(subject).to warn_with(/token contains version designation/)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not warn about version in token if the cask is from the `cask-versions` tap" do
|
|
|
|
allow(cask).to receive(:tap).and_return(Tap.fetch("homebrew/cask-versions"))
|
|
|
|
|
|
|
|
expect(subject).not_to warn_with(/token contains version designation/)
|
2020-06-04 23:11:51 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token contains launcher" do
|
|
|
|
let(:cask_token) { "token-launcher" }
|
|
|
|
|
|
|
|
it "warns about launcher in token" do
|
|
|
|
expect(subject).to warn_with(/token mentions launcher/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token contains desktop" do
|
|
|
|
let(:cask_token) { "token-desktop" }
|
|
|
|
|
|
|
|
it "warns about desktop in token" do
|
|
|
|
expect(subject).to warn_with(/token mentions desktop/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token contains platform" do
|
|
|
|
let(:cask_token) { "token-osx" }
|
|
|
|
|
|
|
|
it "warns about platform in token" do
|
|
|
|
expect(subject).to warn_with(/token mentions platform/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token contains architecture" do
|
|
|
|
let(:cask_token) { "token-x86" }
|
|
|
|
|
|
|
|
it "warns about architecture in token" do
|
|
|
|
expect(subject).to warn_with(/token mentions architecture/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token contains framework" do
|
|
|
|
let(:cask_token) { "token-java" }
|
|
|
|
|
|
|
|
it "warns about framework in token" do
|
|
|
|
expect(subject).to warn_with(/cask token mentions framework/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token is framework" do
|
|
|
|
let(:cask_token) { "java" }
|
|
|
|
|
|
|
|
it "does not warn about framework" do
|
|
|
|
expect(subject).not_to warn_with(/token contains version/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-04 23:37:54 +02:00
|
|
|
describe "locale validation" do
|
|
|
|
let(:cask) do
|
|
|
|
tmp_cask "locale-cask-test", <<~RUBY
|
|
|
|
cask 'locale-cask-test' do
|
|
|
|
version '1.0'
|
|
|
|
url "https://brew.sh/"
|
|
|
|
name 'Audit'
|
|
|
|
homepage 'https://brew.sh/'
|
|
|
|
app 'Audit.app'
|
|
|
|
|
|
|
|
language 'en', default: true do
|
|
|
|
sha256 '96574251b885c12b48a3495e843e434f9174e02bb83121b578e17d9dbebf1ffb'
|
|
|
|
'zh-CN'
|
|
|
|
end
|
|
|
|
|
|
|
|
language 'zh-CN' do
|
|
|
|
sha256 '96574251b885c12b48a3495e843e434f9174e02bb83121b578e17d9dbebf1ffb'
|
|
|
|
'zh-CN'
|
|
|
|
end
|
|
|
|
|
|
|
|
language 'ZH-CN' do
|
|
|
|
sha256 '96574251b885c12b48a3495e843e434f9174e02bb83121b578e17d9dbebf1ffb'
|
|
|
|
'zh-CN'
|
|
|
|
end
|
|
|
|
|
|
|
|
language 'zh-' do
|
|
|
|
sha256 '96574251b885c12b48a3495e843e434f9174e02bb83121b578e17d9dbebf1ffb'
|
|
|
|
'zh-CN'
|
|
|
|
end
|
|
|
|
|
|
|
|
language 'zh-cn' do
|
|
|
|
sha256 '96574251b885c12b48a3495e843e434f9174e02bb83121b578e17d9dbebf1ffb'
|
|
|
|
'zh-CN'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask locale is invalid" do
|
|
|
|
it "error with invalid locale" do
|
2020-08-12 00:04:20 +02:00
|
|
|
expect(subject).to fail_with(/Locale 'ZH-CN' is invalid\./)
|
|
|
|
expect(subject).to fail_with(/Locale 'zh-' is invalid\./)
|
|
|
|
expect(subject).to fail_with(/Locale 'zh-cn' is invalid\./)
|
2020-06-04 23:37:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-25 15:30:16 +10:00
|
|
|
describe "pkg allow_untrusted checks" do
|
2018-09-03 20:12:29 +01:00
|
|
|
let(:warning_msg) { "allow_untrusted is not permitted in official Homebrew Cask taps" }
|
2018-03-25 15:30:16 +10:00
|
|
|
|
|
|
|
context "when the Cask has no pkg stanza" do
|
|
|
|
let(:cask_token) { "basic-cask" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2018-03-25 15:30:16 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the Cask does not have allow_untrusted" do
|
|
|
|
let(:cask_token) { "with-uninstall-pkgutil" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2018-03-25 15:30:16 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the Cask has allow_untrusted" do
|
|
|
|
let(:cask_token) { "with-allow-untrusted" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2018-03-25 15:30:16 +10:00
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
2018-05-19 12:38:47 +10:00
|
|
|
describe "when the Cask stanza requires uninstall" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "installer and pkg stanzas require an uninstall stanza" }
|
2018-05-19 12:38:47 +10:00
|
|
|
|
|
|
|
context "when the Cask does not require an uninstall" do
|
|
|
|
let(:cask_token) { "basic-cask" }
|
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2018-05-19 12:38:47 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the pkg Cask has an uninstall" do
|
|
|
|
let(:cask_token) { "with-uninstall-pkgutil" }
|
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2018-05-19 12:38:47 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the installer Cask has an uninstall" do
|
|
|
|
let(:cask_token) { "installer-with-uninstall" }
|
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2018-05-19 12:38:47 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the installer Cask does not have an uninstall" do
|
|
|
|
let(:cask_token) { "with-installer-manual" }
|
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2018-05-19 12:38:47 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the pkg Cask does not have an uninstall" do
|
|
|
|
let(:cask_token) { "pkg-without-uninstall" }
|
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2018-05-19 12:38:47 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-30 20:47:40 -03:00
|
|
|
describe "preflight stanza checks" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "only a single preflight stanza is allowed" }
|
2017-10-30 20:47:40 -03:00
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has no preflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-zap-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has only one preflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-preflight" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has multiple preflight stanzas" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-preflight-multi" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "uninstall_postflight stanza checks" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "only a single postflight stanza is allowed" }
|
2017-10-30 20:47:40 -03:00
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has no postflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-zap-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has only one postflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-postflight" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has multiple postflight stanzas" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-postflight-multi" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "uninstall stanza checks" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "only a single uninstall stanza is allowed" }
|
2017-10-30 20:47:40 -03:00
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has no uninstall stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-zap-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has only one uninstall stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-uninstall-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has multiple uninstall stanzas" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-uninstall-multi" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "uninstall_preflight stanza checks" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "only a single uninstall_preflight stanza is allowed" }
|
2017-10-30 20:47:40 -03:00
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has no uninstall_preflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-zap-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has only one uninstall_preflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-uninstall-preflight" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has multiple uninstall_preflight stanzas" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-uninstall-preflight-multi" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "uninstall_postflight stanza checks" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "only a single uninstall_postflight stanza is allowed" }
|
2017-10-30 20:47:40 -03:00
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has no uninstall_postflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-zap-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has only one uninstall_postflight stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-uninstall-postflight" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has multiple uninstall_postflight stanzas" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-uninstall-postflight-multi" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "zap stanza checks" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "only a single zap stanza is allowed" }
|
2017-10-30 20:47:40 -03:00
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has no zap stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-uninstall-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has only one zap stanza" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-zap-rmdir" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
|
2018-03-27 08:41:32 +10:00
|
|
|
context "when the Cask has multiple zap stanzas" do
|
2017-10-30 20:47:40 -03:00
|
|
|
let(:cask_token) { "with-zap-multi" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2017-10-30 20:47:40 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-18 22:11:42 +03:00
|
|
|
describe "version checks" do
|
|
|
|
let(:error_msg) { "you should use version :latest instead of version 'latest'" }
|
|
|
|
|
|
|
|
context "when version is 'latest'" do
|
|
|
|
let(:cask_token) { "version-latest-string" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-08-27 11:52:14 +02:00
|
|
|
it { is_expected.to fail_with(error_msg) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when version is :latest" do
|
|
|
|
let(:cask_token) { "version-latest-with-checksum" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
|
|
|
it { is_expected.not_to fail_with(error_msg) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "sha256 checks" do
|
|
|
|
context "when version is :latest and sha256 is not :no_check" do
|
|
|
|
let(:cask_token) { "version-latest-with-checksum" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-08-27 11:52:14 +02:00
|
|
|
it { is_expected.to fail_with("you should use sha256 :no_check when version is :latest") }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when sha256 is not a legal SHA-256 digest" do
|
|
|
|
let(:cask_token) { "invalid-sha256" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-08-27 11:52:14 +02:00
|
|
|
it { is_expected.to fail_with("sha256 string must be of 64 hexadecimal characters") }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when sha256 is sha256 for empty string" do
|
|
|
|
let(:cask_token) { "sha256-for-empty-string" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-10-14 20:03:34 +02:00
|
|
|
it { is_expected.to fail_with(/cannot use the sha256 for an empty string/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-15 17:01:27 +10:00
|
|
|
describe "hosting with appcast checks" do
|
|
|
|
let(:appcast_warning) { /please add an appcast/ }
|
2018-03-26 21:25:00 +10:00
|
|
|
|
2018-06-15 17:01:27 +10:00
|
|
|
context "when the download does not use hosting with an appcast" do
|
2018-03-26 21:25:00 +10:00
|
|
|
let(:cask_token) { "basic-cask" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
it { is_expected.not_to warn_with(appcast_warning) }
|
2018-03-26 21:25:00 +10:00
|
|
|
end
|
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
context "when the download uses GitHub releases and has an appcast" do
|
2018-03-26 21:25:00 +10:00
|
|
|
let(:cask_token) { "github-with-appcast" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
it { is_expected.not_to warn_with(appcast_warning) }
|
2018-03-26 21:25:00 +10:00
|
|
|
end
|
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
context "when the download uses GitHub releases and does not have an appcast" do
|
2018-03-26 21:25:00 +10:00
|
|
|
let(:cask_token) { "github-without-appcast" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
it { is_expected.to warn_with(appcast_warning) }
|
2018-03-26 21:25:00 +10:00
|
|
|
end
|
|
|
|
|
2018-06-15 17:01:27 +10:00
|
|
|
context "when the download is hosted on SourceForge and has an appcast" do
|
|
|
|
let(:cask_token) { "sourceforge-with-appcast" }
|
2018-06-05 16:42:15 +10:00
|
|
|
|
2018-06-15 17:01:27 +10:00
|
|
|
it { is_expected.not_to warn_with(appcast_warning) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the download is hosted on SourceForge and does not have an appcast" do
|
|
|
|
let(:cask_token) { "sourceforge-correct-url-format" }
|
|
|
|
|
|
|
|
it { is_expected.to warn_with(appcast_warning) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the download is hosted on DevMate and has an appcast" do
|
|
|
|
let(:cask_token) { "devmate-with-appcast" }
|
2018-06-05 16:42:15 +10:00
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
it { is_expected.not_to warn_with(appcast_warning) }
|
2018-06-05 16:42:15 +10:00
|
|
|
end
|
|
|
|
|
2018-06-15 17:01:27 +10:00
|
|
|
context "when the download is hosted on DevMate and does not have an appcast" do
|
|
|
|
let(:cask_token) { "devmate-without-appcast" }
|
|
|
|
|
|
|
|
it { is_expected.to warn_with(appcast_warning) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the download is hosted on HockeyApp and has an appcast" do
|
|
|
|
let(:cask_token) { "hockeyapp-with-appcast" }
|
2018-06-05 16:42:15 +10:00
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
it { is_expected.not_to warn_with(appcast_warning) }
|
2018-06-05 16:42:15 +10:00
|
|
|
end
|
|
|
|
|
2018-06-15 17:01:27 +10:00
|
|
|
context "when the download is hosted on HockeyApp and does not have an appcast" do
|
|
|
|
let(:cask_token) { "hockeyapp-without-appcast" }
|
2018-06-05 16:42:15 +10:00
|
|
|
|
2018-06-05 19:20:38 +10:00
|
|
|
it { is_expected.to warn_with(appcast_warning) }
|
2018-06-05 16:42:15 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-27 20:56:01 +10:00
|
|
|
describe "latest with appcast checks" do
|
2018-06-05 19:09:14 +10:00
|
|
|
let(:warning_msg) { "Casks with an appcast should not use version :latest" }
|
2018-03-27 20:56:01 +10:00
|
|
|
|
|
|
|
context "when the Cask is :latest and does not have an appcast" do
|
|
|
|
let(:cask_token) { "version-latest" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2018-03-27 20:56:01 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the Cask is versioned and has an appcast" do
|
|
|
|
let(:cask_token) { "with-appcast" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2018-03-27 20:56:01 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the Cask is :latest and has an appcast" do
|
|
|
|
let(:cask_token) { "latest-with-appcast" }
|
2018-03-28 22:05:56 +10:00
|
|
|
|
2018-06-05 19:09:14 +10:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2018-03-27 20:56:01 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-06 21:10:16 +01:00
|
|
|
describe "denylist checks" do
|
|
|
|
context "when the Cask isn't disallowed" do
|
2019-09-08 09:09:37 -04:00
|
|
|
let(:cask_token) { "adobe-air" }
|
|
|
|
|
|
|
|
it { is_expected.to pass }
|
|
|
|
end
|
|
|
|
|
2020-06-06 21:10:16 +01:00
|
|
|
context "when the Cask is disallowed" do
|
2019-09-08 09:09:37 -04:00
|
|
|
context "and it's in the official Homebrew tap" do
|
|
|
|
let(:cask_token) { "adobe-illustrator" }
|
|
|
|
|
2020-06-06 21:10:16 +01:00
|
|
|
it { is_expected.to fail_with(/#{cask_token} is not allowed: \w+/) }
|
2019-09-08 09:09:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "and it isn't in the official Homebrew tap" do
|
|
|
|
let(:cask_token) { "pharo" }
|
|
|
|
|
|
|
|
it { is_expected.to pass }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-12 16:13:46 +10:00
|
|
|
describe "latest with auto_updates checks" do
|
|
|
|
let(:warning_msg) { "Casks with `version :latest` should not use `auto_updates`" }
|
|
|
|
|
|
|
|
context "when the Cask is :latest and does not have auto_updates" do
|
|
|
|
let(:cask_token) { "version-latest" }
|
|
|
|
|
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the Cask is versioned and does not have auto_updates" do
|
|
|
|
let(:cask_token) { "basic-cask" }
|
|
|
|
|
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the Cask is versioned and has auto_updates" do
|
|
|
|
let(:cask_token) { "auto-updates" }
|
|
|
|
|
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the Cask is :latest and has auto_updates" do
|
|
|
|
let(:cask_token) { "latest-with-auto-updates" }
|
|
|
|
|
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-18 22:11:42 +03:00
|
|
|
describe "preferred download URL formats" do
|
2016-10-14 20:03:34 +02:00
|
|
|
let(:warning_msg) { /URL format incorrect/ }
|
2016-08-18 22:11:42 +03:00
|
|
|
|
|
|
|
context "with incorrect SourceForge URL format" do
|
|
|
|
let(:cask_token) { "sourceforge-incorrect-url-format" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-08-27 11:52:14 +02:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with correct SourceForge URL format" do
|
|
|
|
let(:cask_token) { "sourceforge-correct-url-format" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with correct SourceForge URL format for version :latest" do
|
|
|
|
let(:cask_token) { "sourceforge-version-latest-correct-url-format" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with incorrect OSDN URL format" do
|
|
|
|
let(:cask_token) { "osdn-incorrect-url-format" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2016-08-27 11:52:14 +02:00
|
|
|
it { is_expected.to warn_with(warning_msg) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with correct OSDN URL format" do
|
|
|
|
let(:cask_token) { "osdn-correct-url-format" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
|
|
|
it { is_expected.not_to warn_with(warning_msg) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "generic artifact checks" do
|
|
|
|
context "with relative target" do
|
|
|
|
let(:cask_token) { "generic-artifact-relative-target" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2017-04-06 00:33:31 +02:00
|
|
|
it { is_expected.to fail_with(/target must be absolute path for Generic Artifact/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with absolute target" do
|
|
|
|
let(:cask_token) { "generic-artifact-absolute-target" }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
|
|
|
it { is_expected.not_to fail_with(/target required for Generic Artifact/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "url checks" do
|
|
|
|
context "given a block" do
|
|
|
|
let(:cask_token) { "booby-trap" }
|
|
|
|
|
|
|
|
context "when loading the cask" do
|
|
|
|
it "does not evaluate the block" do
|
2016-08-27 11:52:14 +02:00
|
|
|
expect { cask }.not_to raise_error
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when doing the audit" do
|
|
|
|
it "evaluates the block" do
|
2016-10-14 20:03:34 +02:00
|
|
|
expect(subject).to fail_with(/Boom/)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "token conflicts" do
|
|
|
|
let(:cask_token) { "with-binary" }
|
2020-04-23 21:16:17 +02:00
|
|
|
let(:token_conflicts) { true }
|
2016-08-18 22:11:42 +03:00
|
|
|
|
|
|
|
context "when cask token conflicts with a core formula" do
|
|
|
|
let(:formula_names) { %w[with-binary other-formula] }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2019-03-28 19:16:56 +00:00
|
|
|
it "warns about duplicates" do
|
|
|
|
expect(audit).to receive(:core_formula_names).and_return(formula_names)
|
|
|
|
expect(subject).to warn_with(/possible duplicate/)
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when cask token does not conflict with a core formula" do
|
|
|
|
let(:formula_names) { %w[other-formula] }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
|
|
|
it { is_expected.not_to warn_with(/possible duplicate/) }
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "audit of downloads" do
|
|
|
|
let(:cask_token) { "with-binary" }
|
2018-09-06 08:29:14 +02:00
|
|
|
let(:cask) { Cask::CaskLoader.load(cask_token) }
|
2020-07-21 19:05:55 +02:00
|
|
|
let(:download_double) { instance_double(Cask::Download) }
|
2018-09-06 08:29:14 +02:00
|
|
|
let(:verify) { class_double(Cask::Verify).as_stubbed_const }
|
2016-08-18 22:11:42 +03:00
|
|
|
let(:error_msg) { "Download Failed" }
|
|
|
|
|
2020-07-21 19:05:55 +02:00
|
|
|
before do
|
|
|
|
allow(audit).to receive(:download).and_return(download_double)
|
|
|
|
end
|
|
|
|
|
2019-03-28 19:16:56 +00:00
|
|
|
it "when download and verification succeed it does not fail" do
|
2020-07-21 19:05:55 +02:00
|
|
|
expect(download_double).to receive(:perform)
|
2019-03-28 19:16:56 +00:00
|
|
|
expect(verify).to receive(:all)
|
|
|
|
expect(subject).not_to fail_with(/#{error_msg}/)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
2019-03-28 19:16:56 +00:00
|
|
|
it "when download fails it does not fail" do
|
2020-07-21 19:05:55 +02:00
|
|
|
expect(download_double).to receive(:perform).and_raise(StandardError.new(error_msg))
|
2019-03-28 19:16:56 +00:00
|
|
|
expect(subject).to fail_with(/#{error_msg}/)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
2019-03-28 19:16:56 +00:00
|
|
|
it "when verification fails it does not fail" do
|
2020-07-21 19:05:55 +02:00
|
|
|
expect(download_double).to receive(:perform)
|
2019-03-28 19:16:56 +00:00
|
|
|
expect(verify).to receive(:all).and_raise(StandardError.new(error_msg))
|
|
|
|
expect(subject).to fail_with(/#{error_msg}/)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when an exception is raised" do
|
2018-09-06 08:29:14 +02:00
|
|
|
let(:cask) { instance_double(Cask::Cask) }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2019-09-08 09:09:37 -04:00
|
|
|
it "fails the audit" do
|
|
|
|
expect(cask).to receive(:tap).and_raise(StandardError.new)
|
2019-03-28 19:16:56 +00:00
|
|
|
expect(subject).to fail_with(/exception while auditing/)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
2020-08-10 19:34:38 +02:00
|
|
|
|
|
|
|
describe "without description" do
|
|
|
|
let(:cask_token) { "without-description" }
|
|
|
|
let(:cask) do
|
|
|
|
tmp_cask cask_token.to_s, <<~RUBY
|
|
|
|
cask '#{cask_token}' do
|
|
|
|
version '1.0'
|
|
|
|
sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a'
|
|
|
|
url "https://brew.sh/"
|
|
|
|
name 'Audit'
|
|
|
|
homepage 'https://brew.sh/'
|
|
|
|
app 'Audit.app'
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when `new_cask` is true" do
|
|
|
|
let(:new_cask) { true }
|
|
|
|
|
|
|
|
it "warns" do
|
|
|
|
expect(subject).to warn_with(/should have a description/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when `new_cask` is true" do
|
|
|
|
let(:new_cask) { false }
|
|
|
|
|
|
|
|
it "does not warn" do
|
|
|
|
expect(subject).not_to warn_with(/should have a description/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with description" do
|
|
|
|
let(:cask_token) { "with-description" }
|
|
|
|
let(:cask) do
|
|
|
|
tmp_cask cask_token.to_s, <<~RUBY
|
|
|
|
cask '#{cask_token}' do
|
|
|
|
version '1.0'
|
|
|
|
sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a'
|
|
|
|
url "https://brew.sh/"
|
|
|
|
name 'Audit'
|
|
|
|
desc 'Cask Auditor'
|
|
|
|
homepage 'https://brew.sh/'
|
|
|
|
app 'Audit.app'
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not warn" do
|
|
|
|
expect(subject).not_to warn_with(/should have a description/)
|
|
|
|
end
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|