aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/bottle_collector_test.rb39
-rw-r--r--Library/Homebrew/test/utils/bottles/collector_spec.rb31
2 files changed, 31 insertions, 39 deletions
diff --git a/Library/Homebrew/test/bottle_collector_test.rb b/Library/Homebrew/test/bottle_collector_test.rb
deleted file mode 100644
index 5879da92c..000000000
--- a/Library/Homebrew/test/bottle_collector_test.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require "testing_env"
-require "utils/bottles"
-
-class BottleCollectorTests < Homebrew::TestCase
- def setup
- super
- @collector = Utils::Bottles::Collector.new
- end
-
- def checksum_for(tag)
- @collector.fetch_checksum_for(tag)
- end
-
- def test_collector_returns_passed_tags
- @collector[:lion] = "foo"
- @collector[:mountain_lion] = "bar"
- assert_equal ["bar", :mountain_lion], checksum_for(:mountain_lion)
- end
-
- def test_collector_returns_when_empty
- assert_nil checksum_for(:foo)
- end
-
- def test_collector_returns_nil_for_no_match
- @collector[:lion] = "foo"
- assert_nil checksum_for(:foo)
- end
-
- def test_collector_returns_nil_for_no_match_when_later_tag_present
- @collector[:lion_or_later] = "foo"
- assert_nil checksum_for(:foo)
- end
-
- def test_collector_prefers_exact_matches
- @collector[:lion_or_later] = "foo"
- @collector[:mountain_lion] = "bar"
- assert_equal ["bar", :mountain_lion], checksum_for(:mountain_lion)
- end
-end
diff --git a/Library/Homebrew/test/utils/bottles/collector_spec.rb b/Library/Homebrew/test/utils/bottles/collector_spec.rb
new file mode 100644
index 000000000..73757234e
--- /dev/null
+++ b/Library/Homebrew/test/utils/bottles/collector_spec.rb
@@ -0,0 +1,31 @@
+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
+ end
+end