Move Download
from Auditor
into Audit
.
This commit is contained in:
parent
ee648ef88c
commit
ee09df8db3
@ -17,12 +17,12 @@ module Cask
|
||||
|
||||
attr_predicate :appcast?
|
||||
|
||||
def initialize(cask, appcast: false, download: false,
|
||||
def initialize(cask, appcast: false, download: false, quarantine: nil,
|
||||
token_conflicts: false, online: false, strict: false,
|
||||
new_cask: false, commit_range: nil, command: SystemCommand)
|
||||
@cask = cask
|
||||
@appcast = appcast
|
||||
@download = download
|
||||
@download = Download.new(cask, quarantine: quarantine) if download
|
||||
@online = online
|
||||
@strict = strict
|
||||
@new_cask = new_cask
|
||||
|
@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/download"
|
||||
|
||||
module Cask
|
||||
class Auditor
|
||||
include Checkable
|
||||
@ -66,13 +64,13 @@ module Cask
|
||||
end
|
||||
|
||||
def audit_cask_instance(cask)
|
||||
download = audit_download? && Download.new(cask, quarantine: quarantine?)
|
||||
audit = Audit.new(cask, appcast: audit_appcast?,
|
||||
online: audit_online?,
|
||||
strict: audit_strict?,
|
||||
new_cask: audit_new_cask?,
|
||||
token_conflicts: audit_token_conflicts?,
|
||||
download: download,
|
||||
download: audit_download?,
|
||||
quarantine: quarantine?,
|
||||
commit_range: commit_range)
|
||||
audit.run!
|
||||
puts audit.summary
|
||||
|
@ -15,16 +15,6 @@ describe Cask::Audit, :cask do
|
||||
end
|
||||
end
|
||||
|
||||
matcher :fail do
|
||||
match(&:errors?)
|
||||
end
|
||||
|
||||
matcher :warn do
|
||||
match do |audit|
|
||||
audit.warnings? && !audit.errors?
|
||||
end
|
||||
end
|
||||
|
||||
matcher :fail_with do |error_msg|
|
||||
match do |audit|
|
||||
include_msg?(audit.errors, error_msg)
|
||||
@ -764,23 +754,27 @@ describe Cask::Audit, :cask do
|
||||
describe "audit of downloads" do
|
||||
let(:cask_token) { "with-binary" }
|
||||
let(:cask) { Cask::CaskLoader.load(cask_token) }
|
||||
let(:download) { instance_double(Cask::Download) }
|
||||
let(:download_double) { instance_double(Cask::Download) }
|
||||
let(:verify) { class_double(Cask::Verify).as_stubbed_const }
|
||||
let(:error_msg) { "Download Failed" }
|
||||
|
||||
before do
|
||||
allow(audit).to receive(:download).and_return(download_double)
|
||||
end
|
||||
|
||||
it "when download and verification succeed it does not fail" do
|
||||
expect(download).to receive(:perform)
|
||||
expect(download_double).to receive(:perform)
|
||||
expect(verify).to receive(:all)
|
||||
expect(subject).not_to fail_with(/#{error_msg}/)
|
||||
end
|
||||
|
||||
it "when download fails it does not fail" do
|
||||
expect(download).to receive(:perform).and_raise(StandardError.new(error_msg))
|
||||
expect(download_double).to receive(:perform).and_raise(StandardError.new(error_msg))
|
||||
expect(subject).to fail_with(/#{error_msg}/)
|
||||
end
|
||||
|
||||
it "when verification fails it does not fail" do
|
||||
expect(download).to receive(:perform)
|
||||
expect(download_double).to receive(:perform)
|
||||
expect(verify).to receive(:all).and_raise(StandardError.new(error_msg))
|
||||
expect(subject).to fail_with(/#{error_msg}/)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user