From d81a22c483275876ef4b485acfd9b9e9aa18a317 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 5 Sep 2023 17:29:53 +0900 Subject: [PATCH] Prevent a warning: method redefined; discarding old included ``` [ 3463/25719] JSONGeneratorTest#test_string_ext_included_calls_super/home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/json/json_generator_test.rb:411: warning: method redefined; discarding old included /home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/json/json_generator_test.rb:399: warning: previous definition of included was here ``` http://rubyci.s3.amazonaws.com/debian10/ruby-master/log/20230905T063003Z.log.html.gz --- tests/json_generator_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/json_generator_test.rb b/tests/json_generator_test.rb index 3c4aad65..5f0101d5 100755 --- a/tests/json_generator_test.rb +++ b/tests/json_generator_test.rb @@ -396,6 +396,7 @@ def test_string_ext_included_calls_super included = false Module.alias_method(:included_orig, :included) + Module.remove_method(:included) Module.define_method(:included) do |base| included_orig(base) included = true @@ -408,6 +409,7 @@ def test_string_ext_included_calls_super assert included ensure if Module.private_method_defined?(:included_orig) + Module.remove_method(:included) if Module.method_defined?(:included) Module.alias_method(:included, :included_orig) Module.remove_method(:included_orig) end