aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/test_formula_spec_selection.rb
blob: 12b290b1e3a2f1b7cc80219a63f7c4555ef7d5fc (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require 'testing_env'
require 'formula'

class FormulaSpecSelectionTests < Homebrew::TestCase
  def test_selects_stable_by_default
    f = formula {
      url "foo-1.0"
      devel { url "foo-1.1a" }
      head "foo"
    }

    assert_predicate f, :stable?
  end

  def test_selects_stable_when_exclusive
    f = formula { url "foo-1.0" }
    assert_predicate f, :stable?
  end

  def test_selects_devel_before_head
    f = formula {
      devel { url "foo-1.1a" }
      head "foo"
    }

    assert_predicate f, :devel?
  end

  def test_selects_devel_when_exclusive
    f = formula { devel { url "foo-1.1a" } }
    assert_predicate f, :devel?
  end

  def test_selects_head_when_exclusive
    f = formula { head "foo" }
    assert_predicate f, :head?
  end

  def test_incomplete_spec_not_selected
    f = formula {
      sha1 TEST_SHA1
      version "1.0"
      head "foo"
    }

    assert_predicate f, :head?
  end

  def test_incomplete_stable_not_set
    f = formula {
      sha1 TEST_SHA1
      devel { url "foo-1.1a" }
      head "foo"
    }

    assert_nil f.stable
    assert_predicate f, :devel?
  end

  def test_selects_head_when_requested
    f = formula("test", Pathname.new(__FILE__).expand_path, :head) {
      url "foo-1.0"
      devel { url "foo-1.1a" }
      head "foo"
    }

    assert_predicate f, :head?
  end

  def test_selects_devel_when_requested
    f = formula("test", Pathname.new(__FILE__).expand_path, :devel) {
      url "foo-1.0"
      devel { url "foo-1.1a" }
      head "foo"
    }

    assert_predicate f, :devel?
  end

  def test_incomplete_devel_not_set
    f = formula {
      url "foo-1.0"
      devel { version "1.1a" }
      head "foo"
    }

    assert_nil f.devel
    assert_predicate f, :stable?
  end

  def test_does_not_raise_for_missing_spec
    f = formula("test", Pathname.new(__FILE__).expand_path, :devel) {
      url "foo-1.0"
      head "foo"
    }

    assert_predicate f, :stable?
  end
end