File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
rspec/object_inspection/inspectors Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,12 @@ def self.an_instance_of_something?(value)
68
68
value . base_matcher . is_a? ( ::RSpec ::Matchers ::BuiltIn ::BeAnInstanceOf )
69
69
end
70
70
71
+ # HINT: `an_instance_of` is a matcher in the rspec-expectations gem.
72
+ # `instance_of` is an argument matcher in the rspec-mocks gem.
73
+ def self . instance_of_something? ( value )
74
+ value . is_a? ( ::RSpec ::Mocks ::ArgumentMatchers ::InstanceOf )
75
+ end
76
+
71
77
def self . a_value_within_something? ( value )
72
78
fuzzy_object? ( value ) &&
73
79
value . base_matcher . is_a? ( ::RSpec ::Matchers ::BuiltIn ::BeWithin )
Original file line number Diff line number Diff line change @@ -4,15 +4,20 @@ module ObjectInspection
4
4
module Inspectors
5
5
class InstanceOf < SuperDiff ::ObjectInspection ::Inspectors ::Base
6
6
def self . applies_to? ( value )
7
- SuperDiff ::RSpec . an_instance_of_something? ( value )
7
+ SuperDiff ::RSpec . an_instance_of_something? ( value ) || SuperDiff :: RSpec . instance_of_something? ( value )
8
8
end
9
9
10
10
protected
11
11
12
12
def inspection_tree
13
13
SuperDiff ::ObjectInspection ::InspectionTree . new do
14
- add_text do |aliased_matcher |
15
- "#<an instance of #{ aliased_matcher . expected } >"
14
+ add_text do |value |
15
+ klass = if SuperDiff ::RSpec . an_instance_of_something? ( value )
16
+ value . expected
17
+ else
18
+ value . instance_variable_get ( :@klass )
19
+ end
20
+ "#<an instance of #{ klass } >"
16
21
end
17
22
end
18
23
end
You can’t perform that action at this time.
0 commit comments