From fa25f7ae59bb1319c70458ba00df8a299ac27463 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <ace@haxalot.com> Date: Tue, 18 Oct 2022 13:40:14 +0200 Subject: [PATCH] util/extensions: Improve pretty printing Should now support beautiful output both for regular running as well as during testing when components may have mocked methods attached to them --- lib/matrix_sdk/util/extensions.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/matrix_sdk/util/extensions.rb b/lib/matrix_sdk/util/extensions.rb index 055d1bb..977d587 100644 --- a/lib/matrix_sdk/util/extensions.rb +++ b/lib/matrix_sdk/util/extensions.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'pp' - unless Object.respond_to? :yield_self class Object def yield_self @@ -52,9 +50,9 @@ module MatrixSdk end def ignore_inspect(*symbols) - class_eval %* - include PP::ObjectMixin + require 'pp' + class_eval %* def pretty_print_instance_variables instance_variables .reject { |f| %i[#{symbols.map { |s| "@#{s}" }.join ' '}].include? f } @@ -62,7 +60,9 @@ module MatrixSdk end def pretty_print(pp) - pp.pp(self) + return pp.pp(self) if respond_to? :mocha_inspect + + pp.pp_object(self) end alias inspect pretty_print_inspect -- GitLab