diff --git a/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb new file mode 100644 index 0000000000..b520a88df8 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb @@ -0,0 +1,61 @@ +require "spec_helper" + +describe Hbc::CLI::Audit do + let(:auditor) { double } + let(:cask) { double } + + describe "selection of Casks to audit" do + it "audits all Casks if no tokens are given" do + allow(Hbc).to receive(:all).and_return([cask, cask]) + + expect(auditor).to receive(:audit).twice + + run_audit([], auditor) + end + + it "audits specified Casks if tokens are given" do + cask_token = "nice-app" + expect(Hbc).to receive(:load).with(cask_token).and_return(cask) + + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + + run_audit([cask_token], auditor) + end + end + + describe "rules for downloading a Cask" do + it "does not download the Cask per default" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + + run_audit(["casktoken"], auditor) + end + + it "download a Cask if --download flag is set" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: true, check_token_conflicts: false) + + run_audit(["casktoken", "--download"], auditor) + end + end + + describe "rules for checking token conflicts" do + it "does not check for token conflicts per default" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + + run_audit(["casktoken"], auditor) + end + + it "checks for token conflicts if --token-conflicts flag is set" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: true) + + run_audit(["casktoken", "--token-conflicts"], auditor) + end + end + + def run_audit(args, auditor) + Hbc::CLI::Audit.new(args, auditor).run + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/audit_test.rb b/Library/Homebrew/cask/test/cask/cli/audit_test.rb deleted file mode 100644 index 89a7d140ab..0000000000 --- a/Library/Homebrew/cask/test/cask/cli/audit_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -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.stub :all, [cask, cask] do - auditor.expects(:audit).times(2) - - run_audit([], auditor) - end - 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, check_token_conflicts: 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.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - - run_audit(["casktoken"], auditor) - end - end - - it "download a Cask if --download flag is set" do - Hbc.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: true, check_token_conflicts: false) - - run_audit(["casktoken", "--download"], auditor) - end - end - end - - describe "rules for checking token conflicts" do - it "does not check for token conflicts per default" do - Hbc.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - - run_audit(["casktoken"], auditor) - end - end - - it "checks for token conflicts if --token-conflicts flag is set" do - Hbc.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: true) - - run_audit(["casktoken", "--token-conflicts"], auditor) - end - end - end - - def run_audit(args, auditor) - Hbc::CLI::Audit.new(args, auditor).run - end -end