aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2014-08-13 08:45:07 +0100
committerMike McQuaid2014-08-13 08:45:07 +0100
commit00d1bb8d12126b415bd2737b08dd4af35a76ac9e (patch)
tree7c02d5e73cb6cd53afababe10b34c3d554e5f194 /Library
parenta61c3615d28e717b273b4b81cc3b956662f63471 (diff)
downloadbrew-00d1bb8d12126b415bd2737b08dd4af35a76ac9e.tar.bz2
Revert "Remove unused branches from Options.coerce"
This reverts commit cee42c339e7632eab15111e2c4e6c121ace6f9e2.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/options.rb2
-rw-r--r--Library/Homebrew/test/test_options.rb9
2 files changed, 11 insertions, 0 deletions
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb
index 86be67ea9..6b982a405 100644
--- a/Library/Homebrew/options.rb
+++ b/Library/Homebrew/options.rb
@@ -116,6 +116,8 @@ class Options
def self.coerce(arg)
case arg
+ when self then arg
+ when Option then new << arg
when Array
opts = new
arg.each do |a|
diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb
index 250360a30..4b9915874 100644
--- a/Library/Homebrew/test/test_options.rb
+++ b/Library/Homebrew/test/test_options.rb
@@ -132,6 +132,15 @@ class OptionsTests < Homebrew::TestCase
assert_equal [foo, bar, baz].sort, (@options | options).to_a.sort
end
+ def test_coerce_with_options
+ assert_same @options, Options.coerce(@options)
+ end
+
+ def test_coerce_with_option
+ option = Option.new("foo")
+ assert_equal option, Options.coerce(option).to_a.first
+ end
+
def test_coerce_with_array
array = %w{--foo --bar}
option1 = Option.new("foo")