onsi / gomega

Ginkgo's Preferred Matcher Library
http://onsi.github.io/gomega/
MIT License
2.15k stars 282 forks source link

docs: wrong example by using ContainsSubstring #672

Closed williandandrade closed 1 year ago

williandandrade commented 1 year ago

Hi, just a little godoc issue at https://pkg.go.dev/github.com/onsi/gomega@v1.27.7#MatchError

In the example it says:

Expect(err).Should(MatchError("an error")) //asserts that err.Error() == "an error"
Expect(err).Should(MatchError(SomeError)) //asserts that err == SomeError (via reflect.DeepEqual)
Expect(err).Should(MatchError(ContainsSubstring("sprocket not found"))) // asserts that edrr.Error() contains substring "sprocket not found"

But the correct method to use is ContainSubstring.

I found another file to be updated, so here is the two files:

onsi commented 1 year ago

thanks - are you up for submitting a PR for this?

williandandrade commented 1 year ago

sure