From 8e2aa1601179c0bb8953fcd30b45ce4d1af38a30 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 14 Apr 2026 13:28:04 +0900 Subject: [PATCH] Adapt color test expectation for IRB >= 1.18.0 IRB 1.18.0 (ruby/irb#1189) highlights struct member names in cyan. Branch the expected value by IRB version so the test passes with both old and new IRB. Guard the check with defined?(IRB::VERSION) for environments where IRB is not available. Co-Authored-By: Claude Opus 4.6 (1M context) --- test/console/color_test.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/console/color_test.rb b/test/console/color_test.rb index 8f62dce45..f81b6b051 100644 --- a/test/console/color_test.rb +++ b/test/console/color_test.rb @@ -33,7 +33,14 @@ def bar end end - { "#{GREEN}##{CLEAR}\n": dummy_class.new('b'), + # IRB >= 1.18.0 highlights struct member names in cyan (ruby/irb#1189) + if defined?(IRB::VERSION) && Gem::Version.new(IRB::VERSION) >= Gem::Version.new("1.18.0") + struct_foo = "#{CYAN}foo#{CLEAR}" + else + struct_foo = "foo" + end + + { "#{GREEN}##{CLEAR}\n": dummy_class.new('b'), "#{RED}#{BOLD}\"#{CLEAR}#{RED}hoge#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}\n": 'hoge'}.each do |k, v| expected = k.to_s obj = v