homebrew-cask-versions/test/cask/cli/audit_test.rb
Roland Walker 202d6019f8 Move all code under an Hbc:: namespace
* convert existing Cask:: namespace to Hbc::
* move Homebrew-fork code under Hbc::
* move freestanding classes such as Tty and TopologicalHash under Hbc::
* recast HOMEBREW_CASK_ constants as HBC_
* modify our Homebrew Formula for backward compatibility
* devscripts and dev docs
2015-01-02 07:27:03 -05:00

45 lines
1.1 KiB
Ruby

require 'test_helper'
describe Hbc::CLI::Audit do
let(:auditor) { mock() }
let(:cask) { mock() }
describe 'selection of Casks to audit' do
it 'audits all Casks if no tokens are given' do
Hbc.stubs(:all => [cask, cask])
auditor.expects(:audit).times(2)
run_audit([], auditor)
end
it 'audits specified Casks if tokens are given' do
cask_token = 'nice-app'
Hbc.expects(:load).with(cask_token).returns(cask)
auditor.expects(:audit).with(cask, :audit_download => false)
run_audit([cask_token], auditor)
end
end
describe 'rules for downloading a Cask' do
it 'does not download the Cask per default' do
Hbc.stubs(:load => cask)
auditor.expects(:audit).with(cask, :audit_download => false)
run_audit(['casktoken'], auditor)
end
it 'download a Cask if --download flag is set' do
Hbc.stubs(:load => cask)
auditor.expects(:audit).with(cask, :audit_download => true)
run_audit(['casktoken', '--download'], auditor)
end
end
def run_audit(args, auditor)
Hbc::CLI::Audit.new(args, auditor).run
end
end