From c6060ec18cbf36fbec1a68b5f8874b3972540acb Mon Sep 17 00:00:00 2001 From: ono-max Date: Tue, 13 Jul 2021 17:28:29 +0900 Subject: [PATCH] solve the warning `warning: redefining constant Struct::SESSION` --- test/color_test.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/color_test.rb b/test/color_test.rb index 497e7b118..cbb1e4f14 100644 --- a/test/color_test.rb +++ b/test/color_test.rb @@ -94,13 +94,12 @@ def test_colorize_does_not_color_string_if_do_not_use_colorize CONFIG[:no_color] = nil end + SESSION_class = Struct.new('SESSION') + private def stub_width_method - # When defining `Struct.new('SESSION')` directly under the class to solve - # `warning: redefining constant`, RR::Errors::DoubleNotFoundError occurred in - # testing of Github workflow. - DEBUGGER__.const_set('SESSION', Struct.new('SESSION')) + DEBUGGER__.const_set('SESSION', SESSION_class) stub(::DEBUGGER__::SESSION).width { IO.console_size[1] } end