summaryrefslogtreecommitdiff
path: root/test/error_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/error_test.rb')
-rw-r--r--test/error_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/error_test.rb b/test/error_test.rb
index d9c71ab..341fa75 100644
--- a/test/error_test.rb
+++ b/test/error_test.rb
@@ -63,3 +63,18 @@ describe Slop::MissingRequiredOption do
opts.parse []
end
end
+
+describe Slop::InvalidOptionValue do
+ it "raises when an option has an invalid value" do
+ opts = Slop::Options.new(validate_types: true)
+ opts.integer "-n", "--number", default: 10
+ assert_raises(Slop::InvalidOptionValue) { opts.parse %w(-n foo) }
+ end
+
+ it "does not raise when errors are suppressed" do
+ opts = Slop::Options.new(validate_types: true, suppress_errors: true)
+ opts.integer "-n", "--number", default: 10
+ r = opts.parse %w(-n foo)
+ assert_equal(10, r[:n])
+ end
+end