aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-08 11:58:34 +0100
committerMarkus Reiter2017-02-10 17:19:19 +0100
commit9e31b51cb0f14ca8e9491de90248532fc44f123f (patch)
treedca86cd0c71ab4255b764df766cdfd352c78d0ba /Library
parentd197e79d35c121fbd79491886cf6d13b8037faef (diff)
downloadbrew-9e31b51cb0f14ca8e9491de90248532fc44f123f.tar.bz2
Convert Audit test to spec.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/audit_spec.rb61
-rw-r--r--Library/Homebrew/cask/test/cask/cli/audit_test.rb64
2 files changed, 61 insertions, 64 deletions
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 000000000..b520a88df
--- /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 89a7d140a..000000000
--- 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