Convert Utils::Bottles::Collector test to spec.

This commit is contained in:
Markus Reiter 2017-02-12 21:37:46 +01:00
parent 9f31d41fb2
commit 6dfbf7066b
3 changed files with 19 additions and 27 deletions

View File

@ -1,27 +0,0 @@
require "testing_env"
require "utils/bottles"
class OSMacBottleCollectorTests < Homebrew::TestCase
def setup
super
@collector = Utils::Bottles::Collector.new
end
def checksum_for(tag)
@collector.fetch_checksum_for(tag)
end
def test_collector_finds_or_later_tags
@collector[:lion_or_later] = "foo"
assert_equal ["foo", :lion_or_later], checksum_for(:mountain_lion)
assert_nil checksum_for(:snow_leopard)
end
def test_collector_finds_altivec_tags
@collector[:tiger_altivec] = "foo"
assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4)
assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4e)
assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g5)
assert_nil checksum_for(:tiger_g3)
end
end

View File

@ -29,6 +29,11 @@ TEST_DIRECTORIES = [
RSpec.configure do |config| RSpec.configure do |config|
config.order = :random config.order = :random
config.include(Test::Helper::Shutup) config.include(Test::Helper::Shutup)
config.before(:each) do |example|
if example.metadata[:needs_macos]
skip "not on macOS" unless OS.mac?
end
end
config.around(:each) do |example| config.around(:each) do |example|
begin begin
TEST_DIRECTORIES.each(&:mkpath) TEST_DIRECTORIES.each(&:mkpath)

View File

@ -27,5 +27,19 @@ describe Utils::Bottles::Collector do
subject[:mountain_lion] = "bar" subject[:mountain_lion] = "bar"
expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["bar", :mountain_lion]) expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["bar", :mountain_lion])
end 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
end end