Skip to content

Conversation

@mcmire
Copy link
Collaborator

@mcmire mcmire commented Apr 11, 2020

The have_attributes matcher is not "supposed" to be used against a
hash, but considering Hash is an object, it is still a perfectly valid
use case. Still, typically, such a test will probably fail, and so the
failure should show an appropriate diff. Currently, the representation
of the subject in said diff is very low-level, as the DefaultObject diff
formatter is being utilized (as Differs::ObjectHavingAttributes inherits
from Differs::DefaultObject, and Differs::DefaultObject uses
DiffFormatters::DefaultObject). Instead we should be using whatever
DiffFormatter is appropriate for the type of subject: hash, array, etc.
Changing this is non-trivial, but it is this with which the majority of
this commit is concerned.

The `have_attributes` matcher is not "supposed" to be used against a
hash, but considering Hash is an object, it is still a perfectly valid
use case. Still, typically, such a test will probably fail, and so the
failure should show an appropriate diff. Currently, the representation
of the subject in said diff is very low-level, as the DefaultObject diff
formatter is being utilized (as Differs::ObjectHavingAttributes inherits
from Differs::DefaultObject, and Differs::DefaultObject uses
DiffFormatters::DefaultObject). Instead we should be using whatever
DiffFormatter is appropriate for the type of subject: hash, array, etc.
Changing this is non-trivial, but it is this with which the majority of
this commit is concerned.
@mcmire mcmire merged commit 08e2b0d into master Apr 11, 2020
@mcmire mcmire deleted the comparing-hash-against-have-attributes branch April 11, 2020 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant