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: collections matchers should display type of expectation #408

Merged
merged 1 commit into from
Feb 1, 2021

Conversation

blgm
Copy link
Collaborator

@blgm blgm commented Jan 31, 2021

The collections matchers ConsistOf() and ContainElements() are often
used with collections of consistent type, for example:

Expect(t).To(ConsistOf(1, 2, 3))

When this fails, it's more helpful to report:

...to contain elements <[]int | len:3, cap:3>: [1, 2, 3]

Than the previous behavior:

...to contain elements <[]interface {} | len:3, cap:3>: [1, 2, 3]

By using []interface{} only where there's no other option we make it
easier to debug issues - especially for types that display identically.

The collections matchers ConsistOf() and ContainElements() are often
used with collections of consistent type, for example:

Expect(t).To(ConsistOf(1, 2, 3))

When this fails, it's more helpful to report:

   ...to contain elements <[]int | len:3, cap:3>: [1, 2, 3]

Than the previous behavior:

   ...to contain elements <[]interface {} | len:3, cap:3>: [1, 2, 3]

By using []interface{} only where there's no other option we make it
easier to debug issues - especially for types that display identically.
@onsi
Copy link
Owner

onsi commented Feb 1, 2021

hey @blgm - this looks good to me. ready for me to merge it in (or you can too, of course!)

@blgm blgm merged commit 6b4eb5a into master Feb 1, 2021
@blgm blgm deleted the collections-types branch February 1, 2021 21:36
This was referenced Mar 8, 2021
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.

None yet

2 participants