You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the have_attributes matcher is used as part of a compound matcher, its actual method is not used when building the diff message, resulting in a diff that is not showing the non-matching values. It seems that within a compound matcher the BaseMatcher#actual method is used.
Your environment
Ruby version: 2.7
rspec-expectations version: 3.12
Steps to reproduce
Call the have_attributes matcher within a compound matcher.
RSpec.describe'A simple struct'doit'has an id'doobj=Struct.new(:id).new(id: 1)expect(obj).tobe_a(Struct).andhave_attributes(id: 2)endend
Expected behavior
The error message should be
Failure/Error: expect(obj).to be_a(Struct).and have_attributes(id: 2)
expected #<struct id=1> to have attributes {:id => 2} but had attributes {:id => 1}
Diff for (have attributes {:id => 2}):
@@ -1 +1 @@
-:id => 2,
+:id => 1,
Actual behavior
The actual message is
Failure/Error: expect(obj).to be_a(Struct).and have_attributes(id: 2)
expected #<struct id=1> to have attributes {:id => 2} but had attributes {:id => 1}
Diff for (have attributes {:id => 2}):
@@ -1 +1 @@
-:id => 2,
+"#<struct id=1>"
The text was updated successfully, but these errors were encountered:
Subject of the issue
When the
have_attributes
matcher is used as part of a compound matcher, itsactual
method is not used when building the diff message, resulting in a diff that is not showing the non-matching values. It seems that within a compound matcher theBaseMatcher#actual
method is used.Your environment
Steps to reproduce
Call the
have_attributes
matcher within a compound matcher.Expected behavior
The error message should be
Actual behavior
The actual message is
The text was updated successfully, but these errors were encountered: