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

Add HaveExactElements matcher #634

Merged
merged 2 commits into from Feb 16, 2023
Merged

Conversation

rickyson96
Copy link
Contributor

This is the PR for implementing the ordered matcher.

Closes #622

@rickyson96
Copy link
Contributor Author

I wanted to implement some mechanism of reporting the matching failure.
Something like this

Expected
    <[]int | len:2, cap:2>: [1, 2]
to have exact elements with
    <[]int | len:2, cap:2>: [2, 1]
the mismatch indexes were:
    index: 0, actual: 1, expects: to equal 2
    index: 1, actual: 2, expects: to equal 1

I'm thinking of utilizing the matcher messages used to fail the elements, but don't want to have the newlines.
Is there anyway to do that? Or maybe other alternative solution?

Thanks! 😄

@onsi
Copy link
Owner

onsi commented Feb 5, 2023

hey! sorry for the delay - thanks for pulling this together. i'll take a look tomorrow and share feedback/pull it in. for now - it looks like one of the tests failed on ci?

@onsi
Copy link
Owner

onsi commented Feb 6, 2023

Ok - took a look and this looks good to me. i don't think it's gonna be super easy to generically remove the new lines in the responses - but I think it's fine to err on the verbose side:

Expected
    <[]int | len:2, cap:2>: [1, 2]
to have exact elements with
    <[]int | len:2, cap:2>: [2, 1]
the mismatch indexes were:
    0: Expected
        <int>: 1
    to equal:
        <int>: 2
    1: Expected
        <int>: 2
    to equal:
        <int>: 1

@rickyson96
Copy link
Contributor Author

Hi, sorry for the late response.

I have updated the implementation on the test reporting.
I have also fixed the failed test, seems like I accidentaly ran ginkgo bootstrap there

@onsi
Copy link
Owner

onsi commented Feb 15, 2023

Looks great, thanks - I'll merge this in after the tests go green. Would you be up for adding a brief snippet of documentation to docs/index.md ? Fine if not, I can do it after I pull it in.

Thanks!

@rickyson96
Copy link
Contributor Author

done! 😁

@onsi onsi merged commit 9d50783 into onsi:master Feb 16, 2023
@rickyson96 rickyson96 deleted the feat/have_exact_elements branch February 17, 2023 08:40
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.

Is there any support for matching ordered slice?
2 participants