summaryrefslogtreecommitdiff
path: root/test/option_test.rb
diff options
context:
space:
mode:
authorAmon Sha <amon.sha@gmail.com>2012-01-26 17:38:44 +0200
committerAmon Sha <amon.sha@gmail.com>2012-01-27 13:03:27 +0200
commitdeef8a7f3c160f489de2916d164c543819b213ed (patch)
tree32c67111b032cba38ee6a69bcac5d325598d81b5 /test/option_test.rb
parenta7374247d49a382316bc339b19dba301b3b7e2b3 (diff)
downloadslop-deef8a7f3c160f489de2916d164c543819b213ed.tar.gz
Add strict checks for integer and float arguments
Diffstat (limited to 'test/option_test.rb')
-rw-r--r--test/option_test.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/option_test.rb b/test/option_test.rb
index c888073..dc7e987 100644
--- a/test/option_test.rb
+++ b/test/option_test.rb
@@ -56,6 +56,14 @@ class OptionTest < TestCase
opts.on :f=, :as => Integer
opts.parse %w'-f 1'
assert_equal 1, opts[:f]
+
+ opts = Slop.new(:strict => true) { on :r=, :as => Integer }
+ assert_raises(Slop::InvalidArgumentError) { opts.parse %w/-r abc/ }
+ end
+
+ test "float type cast" do
+ opts = Slop.new(:strict => true) { on :r=, :as => Float }
+ assert_raises(Slop::InvalidArgumentError) { opts.parse %w/-r abc/ }
end
test "symbol type cast" do
@@ -115,4 +123,4 @@ class OptionTest < TestCase
slop.on :foo, :help => ' -f, --foo SOMETHING FOOEY'
assert_equal ' -f, --foo SOMETHING FOOEY', slop.fetch_option(:foo).help
end
-end \ No newline at end of file
+end