Remove duplicates from ARGV.named

Includes test
This commit is contained in:
Max Howell 2009-08-07 15:49:58 +01:00
parent dccc2b1923
commit 6dbdc9ab0c
2 changed files with 9 additions and 1 deletions

View File

@ -17,7 +17,7 @@
#
module HomebrewArgvExtension
def named
reject {|arg| arg[0..0] == '-'}
reject{|arg| arg[0..0] == '-'}.collect{|arg| arg.downcase}.uniq
end
def options
select {|arg| arg[0..0] == '-'}

View File

@ -255,4 +255,12 @@ class BeerTasting <Test::Unit::TestCase
assert_raises(RuntimeError) { f.prefix }
nostdout { assert_raises(ExecutionError) { f.brew } }
end
def test_no_ARGV_dupes
ARGV.unshift'foo'
ARGV.unshift'foo'
n=0
ARGV.named.each{|arg| n+=1 if arg == 'foo'}
assert_equal 1, n
end
end