aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/utils/bottles/collector_spec.rb
blob: 08484e5455c6ec86022ca013bd40ccc052f8490c (plain)
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
require "utils/bottles"

describe Utils::Bottles::Collector do
  describe "#fetch_checksum_for" do
    it "returns passed tags" do
      subject[:lion] = "foo"
      subject[:mountain_lion] = "bar"
      expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["bar", :mountain_lion])
    end

    it "returns nil if empty" do
      expect(subject.fetch_checksum_for(:foo)).to be nil
    end

    it "returns nil when there is no match" do
      subject[:lion] = "foo"
      expect(subject.fetch_checksum_for(:foo)).to be nil
    end

    it "returns nil when there is no match and later tag is present" do
      subject[:lion_or_later] = "foo"
      expect(subject.fetch_checksum_for(:foo)).to be nil
    end

    it "prefers exact matches" do
      subject[:lion_or_later] = "foo"
      subject[:mountain_lion] = "bar"
      expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["bar", :mountain_lion])
    end

    it "finds '_or_later' tags", :needs_macos do
      subject[:lion_or_later] = "foo"
      expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["foo", :lion_or_later])
      expect(subject.fetch_checksum_for(:snow_leopard)).to be nil
    end

    it "finds '_altivec' tags", :needs_macos do
      subject[:tiger_altivec] = "foo"
      expect(subject.fetch_checksum_for(:tiger_g4)).to eq(["foo", :tiger_altivec])
      expect(subject.fetch_checksum_for(:tiger_g4e)).to eq(["foo", :tiger_altivec])
      expect(subject.fetch_checksum_for(:tiger_g5)).to eq(["foo", :tiger_altivec])
      expect(subject.fetch_checksum_for(:tiger_g3)).to be nil
    end
  end
end