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

More flexible HaveLen and HaveCap matchers #767

Open
rgalanakis opened this issue Jul 3, 2024 · 1 comment
Open

More flexible HaveLen and HaveCap matchers #767

rgalanakis opened this issue Jul 3, 2024 · 1 comment

Comments

@rgalanakis
Copy link

Hello, long-time Ginkgo/Gomega lover here. I maintain an additional matcher library: https://github.com/rgalanakis/golangal

I know some of them are taste-dependent, but I think the built-in HaveLen and HaveCap matchers can be made more flexible without any downsides:

  • Accept a matcher, rather than an int (ie, HaveLen(BeNumerically(">", 5)))
  • Handle non-built-in-collection types, where they have Len() or Cap() (ie, Expect(bytes.NewBufferString("abc")).To(HaveLength(3)))

I have implementations of these here, or let me know if you'd add this and I can open a PR.

@onsi
Copy link
Owner

onsi commented Jul 3, 2024

love it! yes please do submit a PR!

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

No branches or pull requests

2 participants