diff options
author | Conrad Irwin <conrad.irwin@gmail.com> | 2011-10-13 23:16:07 -0700 |
---|---|---|
committer | Conrad Irwin <conrad.irwin@gmail.com> | 2011-10-13 23:32:25 -0700 |
commit | 0e4ad83fa6791a57475056305ca721485ed9f88e (patch) | |
tree | 38dc20671c9d14d9a2341cbbcecf2dcab5c5d439 /test/option_test.rb | |
parent | 1c9062b42eddb767f463094dedd2b8b5798df560 (diff) | |
download | slop-0e4ad83fa6791a57475056305ca721485ed9f88e.tar.gz |
Support :as => 'count'
This simplifies the API when you want to count arguments.
The typical example is -v for verbose, -vv for very-verbose.
Diffstat (limited to 'test/option_test.rb')
-rw-r--r-- | test/option_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/option_test.rb b/test/option_test.rb index 1eb2d9f..d7eec0e 100644 --- a/test/option_test.rb +++ b/test/option_test.rb @@ -75,6 +75,11 @@ class OptionTest < TestCase assert_equal -1, option_value(%w/-i -1.1/, :i, true, :as => Integer) assert_equal "-1.1", option_value(%w/-i -1.1/, :i, true, :as => Float).to_s assert_equal "foo", option_value(%w/--foo1 foo/, :foo1, true) + + assert_equal 0, option_value(%w//, :v, :verbose, :as => :count) + assert_equal 1, option_value(%w/--verbose/, :v, :verbose, :as => :count) + assert_equal 2, option_value(%w/--verbose -v/, :v, :verbose, :as => :count) + assert_equal 3, option_value(%w/-vvv/, :v, :verbose, :as => :count) end test 'ranges' do |