Skip to content
Snippets Groups Projects
Verified Commit fa25f7ae authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

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
parent 6a766d15
No related branches found
No related tags found
No related merge requests found
Pipeline #79004 passed
# 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment