From 9fbbbadc9634ec4cdfe378bba62bfb706f4bb03a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Jul 2020 17:38:58 +0900 Subject: [PATCH] Added just working Test::Unit::CoreAssertions#diff This is not "diff", but show expected and actual results both, just to get rid of `NoMethodError` when an assertion failed. --- tool/lib/test/unit/core_assertions.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb index adb797ba16..235b116cb7 100644 --- a/tool/lib/test/unit/core_assertions.rb +++ b/tool/lib/test/unit/core_assertions.rb @@ -635,6 +635,22 @@ eom super end end + + def diff(exp, act) + require 'pp' + q = PP.new(+"") + q.guard_inspect_key do + q.group(2, "expected: ") do + q.pp exp + end + q.text q.newline + q.group(2, "actual: ") do + q.pp act + end + q.flush + end + q.output + end end end end