aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/test_bottles.rb
blob: f443020716eeb79e8e7b142159820f70f3eb8af3 (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
require 'testing_env'
require 'test/testball'

# We temporarily redefine bottles_supported? because the
# following tests assume it is true, but other tests may
# expect the real value.
def bottles_are_supported &block
  alias :old_bottles_supported? :bottles_supported?
  def bottles_supported?; true end
  instance_eval(&block)
  def bottles_supported?; old_bottles_supported? end
end

class BottleTests < Test::Unit::TestCase
  def test_bottle_spec_selection
    bottles_are_supported do
      f = SnowLeopardBottleSpecTestBall.new

      assert_equal case MacOS.cat
        when :snowleopard then f.bottle
        else f.stable
        end, f.active_spec

      f = LionBottleSpecTestBall.new
      assert_equal case MacOS.cat
        when :lion then f.bottle
        else f.stable
        end, f.active_spec

      f = AllCatsBottleSpecTestBall.new
      assert_equal f.bottle, f.active_spec
    end
  end
end