From 97b3082cdd195bed875b6ef5530a69e106e324f8 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 1 Aug 2024 00:07:23 -0600 Subject: [PATCH] Disable color when using the string failure message --- src/spectator/matchers/match_data.cr | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spectator/matchers/match_data.cr b/src/spectator/matchers/match_data.cr index ccf80611..73dbc39f 100644 --- a/src/spectator/matchers/match_data.cr +++ b/src/spectator/matchers/match_data.cr @@ -1,3 +1,4 @@ +require "colorize" require "../core/location_range" module Spectator::Matchers @@ -31,7 +32,14 @@ module Spectator::Matchers end struct FailedMatchData < MatchData - getter message : String? + getter message : String do + color_enabled = Colorize.enabled? + begin + to_s + ensure + Colorize.enabled = color_enabled + end + end @proc : (IO ->)?