gomega
gomega copied to clipboard
More flexible HaveLen and HaveCap matchers
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()orCap()(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.
love it! yes please do submit a PR!