aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorJack Nagel2013-09-26 16:59:45 -0500
committerJack Nagel2013-09-26 17:00:00 -0500
commitd1ce5bafc9b33e516ec34daa37efc32b6c367c82 (patch)
tree2b613408d0f2f4e32a94ca5bb4c9eaf7aeca15ae /Library/Homebrew/test
parent1fb9f85c5f6e3ec59b439025b5382110c27ed5ef (diff)
downloadbrew-d1ce5bafc9b33e516ec34daa37efc32b6c367c82.tar.bz2
Raise when given an invalid download strategy spec
When DownloadStrategyDetector.detect is given a second argument, and that argument is not a symbol or an AbstractDownloadStrategy subclass, it is silently ignored, and we fall back to guessing the strategy based on the URL. This means I can do url 'http://foo.com/bar.tar.gz', :using => Class.new and things will appear to work, even though I have clearly passed an invalid value for :using. A more useful behavior is to raise an exception for unknown strategy specifications.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_download_strategies.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb
index ef330de42..3a330e797 100644
--- a/Library/Homebrew/test/test_download_strategies.rb
+++ b/Library/Homebrew/test/test_download_strategies.rb
@@ -51,4 +51,10 @@ class DownloadStrategyDetectorTests < Test::Unit::TestCase
@d = DownloadStrategyDetector.detect(Object.new)
assert_equal CurlDownloadStrategy, @d
end
+
+ def test_raises_when_passed_unrecognized_strategy
+ assert_raises(TypeError) do
+ DownloadStrategyDetector.detect("foo", Class.new)
+ end
+ end
end