Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix diff from using have_attributes with a hash #76

Merged
merged 1 commit into from
Apr 11, 2020

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