aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/verify_spec.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-05 06:31:36 +0100
committerMarkus Reiter2017-03-05 23:08:14 +0100
commit9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 (patch)
tree43e99a683329471c1dc965dcc92daccb57df7e8d /Library/Homebrew/test/cask/verify_spec.rb
parent67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff)
downloadbrew-9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2.tar.bz2
Move Cask specs into `brew tests`.
Diffstat (limited to 'Library/Homebrew/test/cask/verify_spec.rb')
-rw-r--r--Library/Homebrew/test/cask/verify_spec.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/verify_spec.rb b/Library/Homebrew/test/cask/verify_spec.rb
new file mode 100644
index 000000000..5d95fb3a2
--- /dev/null
+++ b/Library/Homebrew/test/cask/verify_spec.rb
@@ -0,0 +1,63 @@
+describe Hbc::Verify, :cask do
+ let(:cask) { double("cask") }
+
+ let(:verification_classes) {
+ [
+ applicable_verification_class,
+ inapplicable_verification_class,
+ ]
+ }
+
+ let(:applicable_verification_class) {
+ double("applicable_verification_class", me?: true)
+ }
+
+ let(:inapplicable_verification_class) {
+ double("inapplicable_verification_class", me?: false)
+ }
+
+ before do
+ allow(described_class).to receive(:verifications)
+ .and_return(verification_classes)
+ end
+
+ describe ".for_cask" do
+ subject { described_class.for_cask(cask) }
+
+ it "checks applicability of each verification" do
+ verification_classes.each do |verify_class|
+ expect(verify_class).to receive(:me?).with(cask)
+ end
+ subject
+ end
+
+ it "includes applicable verifications" do
+ expect(subject).to include(applicable_verification_class)
+ end
+
+ it "excludes inapplicable verifications" do
+ expect(subject).not_to include(inapplicable_verification_class)
+ end
+ end
+
+ describe ".all" do
+ let(:downloaded_path) { double("downloaded_path") }
+ let(:applicable_verification) { double("applicable_verification") }
+ let(:inapplicable_verification) { double("inapplicable_verification") }
+
+ subject { described_class.all(cask, downloaded_path) }
+
+ before do
+ allow(applicable_verification_class).to receive(:new)
+ .and_return(applicable_verification)
+ allow(inapplicable_verification_class).to receive(:new)
+ .and_return(inapplicable_verification)
+ end
+
+ it "runs only applicable verifications" do
+ expect(applicable_verification).to receive(:verify)
+ expect(inapplicable_verification).not_to receive(:verify)
+ subject
+ end
+ end
+end