Merge pull request #2240 from linc01n/audit

Check no_checksum if version is latest in audit
This commit is contained in:
Paul Hinze 2014-01-10 10:59:36 -08:00
commit b850d78427
2 changed files with 15 additions and 0 deletions

View File

@ -13,6 +13,7 @@ class Cask::Audit
def run!(download = false)
_check_required_fields
_check_checksums
_check_no_checksums_if_latest
_check_sourceforge_download_url_format
_check_download(download) if download
end
@ -33,6 +34,10 @@ class Cask::Audit
add_error "could not find checksum or no_checksum" unless cask.sums.is_a?(Array) && cask.sums.length > 0
end
def _check_no_checksums_if_latest
add_error "you should use no_checksum when version is latest" if cask.version == "latest" && cask.sums.is_a?(Array)
end
def _check_download(download)
download.perform
rescue => e

View File

@ -33,6 +33,10 @@ class CaskSourceForgeOtherCorrectURLFormat < Cask
url 'http://sourceforge.net/projects/something/files/latest/download'
end
class CaskVersionLatestWithChecksum < Cask
version 'latest'
sha1 '123456'
end
describe Cask::Audit do
describe "result" do
@ -74,6 +78,12 @@ describe Cask::Audit do
audit.run!
audit.errors.must_include 'homepage is required'
end
it "adds an error if version is latest and using sha1" do
audit = Cask::Audit.new(CaskVersionLatestWithChecksum.new)
audit.run!
audit.errors.must_include 'you should use no_checksum when version is latest'
end
end
describe "preferred download URL formats" do