diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-06 08:23:10 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-06 08:23:10 +0000 |
commit | cfb6723fd6624be21a8c83f482b925dacf27e3e2 (patch) | |
tree | b3fbc07ffeda4a61ca34f64dea679c4a533f0e79 /test | |
parent | 361fa838a3f5a8ba2fd3be9037ce7fa92e40e74d (diff) | |
download | ruby-cfb6723fd6624be21a8c83f482b925dacf27e3e2.tar.gz |
optparse.rb: into kwdarg
* lib/optparse.rb (OptionParser#order!): add `into` optional
keyword argument to store the results. [Feature #11191]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/optparse/test_optparse.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/optparse/test_optparse.rb b/test/optparse/test_optparse.rb index f17f8ee895..a2540db241 100644 --- a/test/optparse/test_optparse.rb +++ b/test/optparse/test_optparse.rb @@ -64,4 +64,15 @@ class TestOptionParser < Test::Unit::TestCase assert_equal(%w"", no_error {@opt.parse!(%w"--regexp=/foo/n")}) assert_equal(/foo/n, @reopt) end + + def test_into + @opt.def_option "-h", "--host=HOST", "hostname" + @opt.def_option "-p", "--port=PORT", "port", Integer + @opt.def_option "-v", "--verbose" do @verbose = true end + @opt.def_option "-q", "--quiet" do @quiet = true end + result = {} + @opt.parse %w(--host localhost --port 8000 -v), into: result + assert_equal({host: "localhost", port: 8000, verbose: true}, result) + assert_equal(true, @verbose) + end end |