diff options
Diffstat (limited to 'test/optparse')
-rw-r--r-- | test/optparse/test_did_you_mean.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/optparse/test_did_you_mean.rb b/test/optparse/test_did_you_mean.rb new file mode 100644 index 0000000000..4d8e272e6b --- /dev/null +++ b/test/optparse/test_did_you_mean.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: false +require_relative 'test_optparse' +require "did_you_mean" rescue return + +class TestOptionParser::DidYouMean < TestOptionParser + def setup + super + @opt.def_option("--foo", Integer) { |v| @foo = v } + @opt.def_option("--bar", Integer) { |v| @bar = v } + @opt.def_option("--baz", Integer) { |v| @baz = v } + end + + def test_did_you_mean + assert_raise(OptionParser::InvalidOption) do + begin + @opt.permute!(%w"--baa") + ensure + assert_equal("invalid option: --baa\nDid you mean? baz\n bar", $!.message) + end + end + end +end |