diff options
| author | Jack Nagel | 2013-04-07 00:49:56 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2013-04-07 20:59:50 -0500 | 
| commit | 446e9888dab891cebe7ca1333f69e5aa26bb2373 (patch) | |
| tree | 24a00236ce76f215cd6cb449e7e6e091db70daf1 | |
| parent | 18f07bb0e7fdb6e474c2d2e85df37225b280205a (diff) | |
| download | homebrew-446e9888dab891cebe7ca1333f69e5aa26bb2373.tar.bz2 | |
Tests for AbstractDownloadStrategy
| -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  | 
