Skip to content

Commit 756eaa0

Browse files
committed
Update BeComparableTo documentation
1 parent 6015576 commit 756eaa0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,14 @@ When both `ACTUAL` and `EXPECTED` are a very long strings, it will attempt to pr
659659

660660
> For asserting equality between numbers of different types, you'll want to use the [`BeNumerically()`](#benumericallycomparator-string-compareto-interface) matcher.
661661
662+
#### BeComparableTo(expected interface{}, options ...cmp.Option)
663+
664+
```go
665+
Ω(ACTUAL).Should(BeComparableTo(EXPECTED, options ...cmp.Option))
666+
```
667+
668+
uses [`gocmp.Equal`](http://github.com/google/go-cmp) from `github.com/google/go-cmp` to compare `ACTUAL` with `EXPECTED`. This performs a deep object comparison like `reflect.DeepEqual` but offers a few additional configuration options. Learn more at the [go-cmp godocs](https://pkg.go.dev/github.com/google/go-cmp).
669+
662670
#### BeEquivalentTo(expected interface{})
663671

664672
```go

matchers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ func BeEquivalentTo(expected interface{}) types.GomegaMatcher {
2727
}
2828
}
2929

30-
// BeComparableTo uses gocmp.Equal to compare. You can pass cmp.Option as options.
30+
// BeComparableTo uses gocmp.Equal from github.com/google/go-cmp (instead of reflect.DeepEqual) to perform a deep comparison.
31+
// You can pass cmp.Option as options.
3132
// It is an error for actual and expected to be nil. Use BeNil() instead.
3233
func BeComparableTo(expected interface{}, opts ...cmp.Option) types.GomegaMatcher {
3334
return &matchers.BeComparableToMatcher{

0 commit comments

Comments
 (0)