diff options
| author | Jack Nagel | 2013-04-07 00:49:56 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-04-07 20:59:50 -0500 |
| commit | 2288f631973b708224d0296f3b6a276c9a714d97 (patch) | |
| tree | cf0a0799b0c1e14755e64f4262ab70de1245051b /Library/Homebrew | |
| parent | 9db0e68eb60b7634eb26f9b734e7b1e47cc3f2ba (diff) | |
| download | brew-2288f631973b708224d0296f3b6a276c9a714d97.tar.bz2 | |
Tests for AbstractDownloadStrategy
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_download_strategies.rb | 36 |
2 files changed, 38 insertions, 1 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 0a0904562..80631d86c 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -8,6 +8,7 @@ class AbstractDownloadStrategy end def expand_safe_system_args args + args = args.dup args.each_with_index do |arg, ii| if arg.is_a? Hash unless ARGV.verbose? @@ -20,7 +21,7 @@ class AbstractDownloadStrategy end # 2 as default because commands are eg. svn up, git pull args.insert(2, '-q') unless ARGV.verbose? - return args + args end def quiet_safe_system *args diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb index 13392272b..fcef2a282 100644 --- a/Library/Homebrew/test/test_download_strategies.rb +++ b/Library/Homebrew/test/test_download_strategies.rb @@ -1,6 +1,42 @@ require 'testing_env' require 'download_strategy' require 'bottles' # XXX: hoist these regexps into constants in Pathname? +require 'hardware' # XXX: wat. fix this require mess! + +class SoftwareSpecDouble + attr_reader :url, :specs + + def initialize(url="http://foo.com/bar.tar.gz", specs={}) + @url = url + @specs = specs + end +end + +class AbstractDownloadStrategyTests < Test::Unit::TestCase + def setup + @name = "foo" + @package = SoftwareSpecDouble.new + @strategy = AbstractDownloadStrategy.new(@name, @package) + @args = %w{foo bar baz} + end + + def test_expand_safe_system_args_with_explicit_quiet_flag + @args << { :quiet_flag => '--flag' } + expanded_args = @strategy.expand_safe_system_args(@args) + assert_equal %w{foo bar baz --flag}, expanded_args + end + + def test_expand_safe_system_args_with_implicit_quiet_flag + expanded_args = @strategy.expand_safe_system_args(@args) + assert_equal %w{foo bar -q baz}, expanded_args + end + + def test_expand_safe_system_args_does_not_mutate_argument + result = @strategy.expand_safe_system_args(@args) + assert_equal %w{foo bar baz}, @args + assert_not_same @args, result + end +end class DownloadStrategyDetectorTests < Test::Unit::TestCase def setup |
