Skip to content

Commit 67b869d

Browse files
authored
updates MatchError godoc comment to also accept a Gomega matcher (#654)
1 parent 5129b5c commit 67b869d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ succeeds if `ACTUAL` is a non-nil `error` that matches `EXPECTED`. `EXPECTED` mu
823823
- `errors.Is(ACTUAL, EXPECTED)` returns `true`
824824
- `ACTUAL` or any of the errors it wraps (directly or indirectly) equals `EXPECTED` in terms of `reflect.DeepEqual()`.
825825

826-
Any other type for `EXPECTED` is an error.
826+
Any other type for `EXPECTED` is an error. It is also an error for `ACTUAL` to be nil.
827827

828828
### Working with Channels
829829

matchers.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,17 @@ func Succeed() types.GomegaMatcher {
8787
return &matchers.SucceedMatcher{}
8888
}
8989

90-
// MatchError succeeds if actual is a non-nil error that matches the passed in string/error.
90+
// MatchError succeeds if actual is a non-nil error that matches the passed in
91+
// string, error, or matcher.
9192
//
9293
// These are valid use-cases:
9394
//
94-
// Expect(err).Should(MatchError("an error")) //asserts that err.Error() == "an error"
95-
// Expect(err).Should(MatchError(SomeError)) //asserts that err == SomeError (via reflect.DeepEqual)
95+
// Expect(err).Should(MatchError("an error")) //asserts that err.Error() == "an error"
96+
// Expect(err).Should(MatchError(SomeError)) //asserts that err == SomeError (via reflect.DeepEqual)
97+
// Expect(err).Should(MatchError(ContainsSubstring("sprocket not found"))) // asserts that edrr.Error() contains substring "sprocket not found"
9698
//
97-
// It is an error for err to be nil or an object that does not implement the Error interface
99+
// It is an error for err to be nil or an object that does not implement the
100+
// Error interface
98101
func MatchError(expected interface{}) types.GomegaMatcher {
99102
return &matchers.MatchErrorMatcher{
100103
Expected: expected,

0 commit comments

Comments
 (0)