diff options
author | Victor Gama <hey@vito.io> | 2023-02-10 16:25:08 -0300 |
---|---|---|
committer | Victor Gama <hey@vito.io> | 2023-02-15 11:43:06 -0300 |
commit | a23fa41a5674485600365985bea2a905e5e087df (patch) | |
tree | c781122a70e710929731ca811cd3f2d7ea4c0023 /test/error_test.rb | |
parent | fc4622fc08d7982847ff583ad691ee4ba47f63f8 (diff) | |
download | slop-a23fa41a5674485600365985bea2a905e5e087df.tar.gz |
Add optional type validation
Diffstat (limited to 'test/error_test.rb')
-rw-r--r-- | test/error_test.rb | 15 |
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 |