gomega icon indicating copy to clipboard operation
gomega copied to clipboard

More flexible HaveLen and HaveCap matchers

Open rgalanakis opened this issue 1 year ago • 1 comments

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.

rgalanakis avatar Jul 03 '24 18:07 rgalanakis

love it! yes please do submit a PR!

onsi avatar Jul 03 '24 19:07 onsi