| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 | describe Hbc::CLI::Audit, :cask do
  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(Hbc::Auditor).to receive(:audit).twice.and_return(true)
      Hbc::CLI::Audit.run
    end
    it "audits specified Casks if tokens are given" do
      cask_token = "nice-app"
      expect(Hbc::CaskLoader).to receive(:load).with(cask_token).and_return(cask)
      expect(Hbc::Auditor).to receive(:audit)
        .with(cask, audit_download: false, check_token_conflicts: false)
        .and_return(true)
      Hbc::CLI::Audit.run(cask_token)
    end
  end
  describe "rules for downloading a Cask" do
    it "does not download the Cask per default" do
      allow(Hbc::CaskLoader).to receive(:load).and_return(cask)
      expect(Hbc::Auditor).to receive(:audit)
        .with(cask, audit_download: false, check_token_conflicts: false)
        .and_return(true)
      Hbc::CLI::Audit.run("casktoken")
    end
    it "download a Cask if --download flag is set" do
      allow(Hbc::CaskLoader).to receive(:load).and_return(cask)
      expect(Hbc::Auditor).to receive(:audit)
        .with(cask, audit_download: true, check_token_conflicts: false)
        .and_return(true)
      Hbc::CLI::Audit.run("casktoken", "--download")
    end
  end
  describe "rules for checking token conflicts" do
    it "does not check for token conflicts per default" do
      allow(Hbc::CaskLoader).to receive(:load).and_return(cask)
      expect(Hbc::Auditor).to receive(:audit)
        .with(cask, audit_download: false, check_token_conflicts: false)
        .and_return(true)
      Hbc::CLI::Audit.run("casktoken")
    end
    it "checks for token conflicts if --token-conflicts flag is set" do
      allow(Hbc::CaskLoader).to receive(:load).and_return(cask)
      expect(Hbc::Auditor).to receive(:audit)
        .with(cask, audit_download: false, check_token_conflicts: true)
        .and_return(true)
      Hbc::CLI::Audit.run("casktoken", "--token-conflicts")
    end
  end
end
 |