summaryrefslogtreecommitdiff
path: root/test/option_test.rb
diff options
context:
space:
mode:
authorLee Jarvis <lee@jarvis.co>2012-01-06 12:42:37 +0000
committerLee Jarvis <lee@jarvis.co>2012-01-06 12:42:37 +0000
commitd39a1a5ff85347ac4522d4ea6a43aae3603159aa (patch)
tree567def762a5758b92e4a2458a5ff344a379d9821 /test/option_test.rb
parentd67fbd30eaae53cab5b525d6afadec47fb740532 (diff)
downloadslop-d39a1a5ff85347ac4522d4ea6a43aae3603159aa.tar.gz
added test for adding custom types
Diffstat (limited to 'test/option_test.rb')
-rw-r--r--test/option_test.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/option_test.rb b/test/option_test.rb
index 49d70d9..2eb3051 100644
--- a/test/option_test.rb
+++ b/test/option_test.rb
@@ -68,10 +68,20 @@ class OptionTest < TestCase
assert_equal (1..-10), option_value(%w/-r 1..-10/, :r=, :as => Range)
end
- test 'array type cast' do
+ test "array type cast" do
assert_equal %w/lee john bill/, option_value(%w/-p lee,john,bill/, :p=, :as => Array)
assert_equal %w/lee john bill/, option_value(%w/-p lee:john:bill/, :p=, :as => Array, :delimiter => ':')
assert_equal %w/lee john,bill/, option_value(%w/-p lee,john,bill/, :p=, :as => Array, :limit => 2)
assert_equal %w/lee john:bill/, option_value(%w/-p lee:john:bill/, :p=, :as => Array, :limit => 2, :delimiter => ':')
end
+
+ test "adding custom types" do
+ opts = Slop.new
+ opt = opts.on :f=, :as => :reverse
+ opt.types['reverse'] = proc { |v| v.reverse }
+ opts.parse %w'-f bar'
+ assert_equal 'rab', opt.value
+ end
+
+ # end type casting tests
end \ No newline at end of file