Skip to content

Commit fa25f7a

Browse files
committed
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
1 parent 6a766d1 commit fa25f7a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/matrix_sdk/util/extensions.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'pp'
4-
53
unless Object.respond_to? :yield_self
64
class Object
75
def yield_self
@@ -52,17 +50,19 @@ def event_initialize
5250
end
5351

5452
def ignore_inspect(*symbols)
55-
class_eval %*
56-
include PP::ObjectMixin
53+
require 'pp'
5754

55+
class_eval %*
5856
def pretty_print_instance_variables
5957
instance_variables
6058
.reject { |f| %i[#{symbols.map { |s| "@#{s}" }.join ' '}].include? f }
6159
.sort
6260
end
6361
6462
def pretty_print(pp)
65-
pp.pp(self)
63+
return pp.pp(self) if respond_to? :mocha_inspect
64+
65+
pp.pp_object(self)
6666
end
6767
6868
alias inspect pretty_print_inspect

0 commit comments

Comments
 (0)