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)
6868 value . base_matcher . is_a? ( ::RSpec ::Matchers ::BuiltIn ::BeAnInstanceOf )
6969 end
7070
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+
7177 def self . a_value_within_something? ( value )
7278 fuzzy_object? ( value ) &&
7379 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
44 module Inspectors
55 class InstanceOf < SuperDiff ::ObjectInspection ::Inspectors ::Base
66 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 )
88 end
99
1010 protected
1111
1212 def inspection_tree
1313 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 } >"
1621 end
1722 end
1823 end
You can’t perform that action at this time.
0 commit comments