From 743a41f7e3e7d4dfad006f23d14a00cbe6ba5946 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 12 Jan 2022 19:37:33 +0900 Subject: [PATCH] [ruby/optparse] DidYouMean::PlainFormatter is deprecated https://github.com/ruby/optparse/commit/0ac9957696 --- test/optparse/test_did_you_mean.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/optparse/test_did_you_mean.rb b/test/optparse/test_did_you_mean.rb index a9ad051f03..14f6ebee17 100644 --- a/test/optparse/test_did_you_mean.rb +++ b/test/optparse/test_did_you_mean.rb @@ -12,12 +12,20 @@ class TestOptionParser::DidYouMean < TestOptionParser @opt.def_option("--foo", Integer) { |v| @foo = v } @opt.def_option("--bar", Integer) { |v| @bar = v } @opt.def_option("--baz", Integer) { |v| @baz = v } - @formatter = ::DidYouMean.formatter - ::DidYouMean.formatter = ::DidYouMean::Formatter + unless ::DidYouMean::Formatter.respond_to?(:message_for) + @formatter = ::DidYouMean.formatter + case @formatter + when ::DidYouMean::PlainFormatter + else + ::DidYouMean.formatter = ::DidYouMean::PlainFormatter.new + end + end end def teardown - ::DidYouMean.formatter = @formatter + unless ::DidYouMean::Formatter.respond_to?(:message_for) + ::DidYouMean.formatter = @formatter + end end def test_no_suggestion