Skip to content

Commit e2eff1f

Browse files
committed
fix several documentation spelling issues
1 parent 36400cb commit e2eff1f

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

docs/index.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Alternatively, such error assertions on multi return value functions can be simp
158158
Ω(MultipleReturnValuesFunc()).Error().Should(HaveOccurred())
159159
```
160160

161-
Similar, asserting that no error occured is supported, too (where the other return values are allowed to take on any value):
161+
Similar, asserting that no error occurred is supported, too (where the other return values are allowed to take on any value):
162162

163163
```go
164164
Ω(MultipleReturnValuesFunc()).Error().ShouldNot(HaveOccured())
@@ -296,7 +296,7 @@ Eventually(c, "50ms").Should(BeClosed())
296296

297297
will poll the channel repeatedly until it is closed. In this example `Eventually` will block until either the specified timeout of 50ms has elapsed or the channel is closed, whichever comes first.
298298

299-
Several Gomega libraries allow you to use Eventually in this way. For example, the `gomega/gexec` package allows you to block until a `*gexec.Session` exits successfuly via:
299+
Several Gomega libraries allow you to use Eventually in this way. For example, the `gomega/gexec` package allows you to block until a `*gexec.Session` exits successfully via:
300300

301301
```go
302302
Eventually(session).Should(gexec.Exit(0))
@@ -368,7 +368,7 @@ You can poll this function like so:
368368
Eventually(FetchFullName).WithArguments(1138).Should(Equal("Wookie"))
369369
```
370370

371-
`WithArguments()` supports multiple arugments as well as variadic arguments.
371+
`WithArguments()` supports multiple arguments as well as variadic arguments.
372372

373373
It is important to note that the function passed into Eventually is invoked **synchronously** when polled. `Eventually` does not (in fact, it cannot) kill the function if it takes longer to return than `Eventually`'s configured timeout. This is where using a `context.Context` can be helpful. Here is an example that leverages Gingko's support for interruptible nodes and spec timeouts:
374374

@@ -407,13 +407,13 @@ It("adds a few books and checks the count", func(ctx SpecContext) {
407407
}, SpecTimeout(time.Second * 5))
408408
```
409409

410-
In addition, Gingko's `SpecContext` allows Gomega to tell Ginkgo about the status of a currently running `Eventually` whenever a Progress Report is generated. So, if a spec times out while running an `Eventually` Ginkgo will not only show you which `Eventually` was running when the timeout occured, but will also include the failure the `Eventually` was hitting when the timeout occurred.
410+
In addition, Gingko's `SpecContext` allows Gomega to tell Ginkgo about the status of a currently running `Eventually` whenever a Progress Report is generated. So, if a spec times out while running an `Eventually` Ginkgo will not only show you which `Eventually` was running when the timeout occurred, but will also include the failure the `Eventually` was hitting when the timeout occurred.
411411

412412
#### Category 3: Making assertions _in_ the function passed into `Eventually`
413413

414414
When testing complex systems it can be valuable to assert that a *set* of assertions passes `Eventually`. `Eventually` supports this by accepting functions that take **a single `Gomega` argument** and **return zero or more values**.
415415

416-
Here's an example that makes some asssertions and returns a value and error:
416+
Here's an example that makes some assertions and returns a value and error:
417417

418418
```go
419419
Eventually(func(g Gomega) (Widget, error) {
@@ -442,7 +442,7 @@ Eventually(func(g Gomega) {
442442

443443
will rerun the function until all assertions pass.
444444

445-
You can also pass additional arugments to functions that take a Gomega. The only rule is that the Gomega argument must be first. If you also want to pass the context attached to `Eventually` you must ensure that is the second argument. For example:
445+
You can also pass additional arguments to functions that take a Gomega. The only rule is that the Gomega argument must be first. If you also want to pass the context attached to `Eventually` you must ensure that is the second argument. For example:
446446

447447
```go
448448
Eventually(func(g Gomega, ctx context.Context, path string, expected ...string){
@@ -800,7 +800,7 @@ succeeds if `ACTUAL` is a non-nil `error` that matches `EXPECTED`. `EXPECTED` mu
800800

801801
- A string, in which case `ACTUAL.Error()` will be compared against `EXPECTED`.
802802
- A matcher, in which case `ACTUAL.Error()` is tested against the matcher.
803-
- An error, in which case anyo of the following is satisfied:
803+
- An error, in which case any of the following is satisfied:
804804
- `errors.Is(ACTUAL, EXPECTED)` returns `true`
805805
- `ACTUAL` or any of the errors it wraps (directly or indirectly) equals `EXPECTED` in terms of `reflect.DeepEqual()`.
806806

@@ -1641,7 +1641,7 @@ type GomegaMatcher interface {
16411641

16421642
For the simplest cases, new matchers can be [created by composition](#composing-matchers). Please also take a look at the [Building Custom Matchers](https://onsi.github.io/ginkgo/#building-custom-matchers) section of the Ginkgo and Gomega patterns chapter in the Ginkgo docs for additional examples.
16431643

1644-
In addition to composition, however, it is fairly straightforward to build domain-specific custom matchers. You can create new types that satisfy the `GomegaMatcher` interace *or* you can use the `gcustom` package to build matchers out of simple functions.
1644+
In addition to composition, however, it is fairly straightforward to build domain-specific custom matchers. You can create new types that satisfy the `GomegaMatcher` interface *or* you can use the `gcustom` package to build matchers out of simple functions.
16451645

16461646
Let's work through an example and illustrate both approaches.
16471647

@@ -1711,7 +1711,7 @@ Let's break this down:
17111711
- It is guaranteed that `FailureMessage` and `NegatedFailureMessage` will only be called *after* `Match`, so you can save off any state you need to compute the messages in `Match`.
17121712
- Finally, it is common for matchers to make extensive use of the `reflect` library to interpret the generic inputs they receive. In this case, the `representJSONMatcher` goes through some `reflect` gymnastics to create a pointer to a new object with the same type as the `expected` object, read and decode JSON from `actual` into that pointer, and then deference the pointer and compare the result to the `expected` object.
17131713

1714-
### gcustom: A convenient mechanism for buildling custom matchers
1714+
### gcustom: A convenient mechanism for building custom matchers
17151715

17161716
[`gcustom`](https://github.com/onsi/gomega/tree/master/gcustom) is a package that makes building custom matchers easy. Rather than define new types, you can simply provide `gcustom.MakeMatcher` with a function. The [godocs](https://pkg.go.dev/github.com/onsi/gomega/gcustom) for `gcustom` have all the details but here's how `RepresentJSONifiedObject` could be implemented with `gcustom`:
17171717

@@ -1903,7 +1903,7 @@ type inner interface {
19031903
}
19041904
```
19051905

1906-
The `Inner()` method must return the actual `gomega.Default`. For Gomega to function properly your wrapper methods must call the same method on the real `gomega.Default` This allows you to wrap every Goemga method call (e.g. `Expect()`) with your own code across your test suite. You can use this to add random delays, additional logging, or just for tracking the number of `Expect()` calls made.
1906+
The `Inner()` method must return the actual `gomega.Default`. For Gomega to function properly your wrapper methods must call the same method on the real `gomega.Default` This allows you to wrap every Gomega method call (e.g. `Expect()`) with your own code across your test suite. You can use this to add random delays, additional logging, or just for tracking the number of `Expect()` calls made.
19071907

19081908
```go
19091909
func init() {
@@ -2467,7 +2467,7 @@ AfterSuite(func() {
24672467
})
24682468
```
24692469

2470-
> By default, `gexec.Build` uses the GOPATH specified in your environment. You can also use `gexec.BuildIn(gopath string, packagePath string)` to specify a custom GOPATH for the build command. This is useful to, for example, build a binary against its vendored Godeps.
2470+
> By default, `gexec.Build` uses the GOPATH specified in your environment. You can also use `gexec.BuildIn(gopath string, packagePath string)` to specify a custom GOPATH for the build command. This is useful to, for example, build a binary against its vendored Go dependencies.
24712471
24722472
> You can specify arbitrary environment variables for the build command – such as GOOS and GOARCH for building on other platforms – using `gexec.BuildWithEnvironment(packagePath string, envs []string)`.
24732473
@@ -2515,7 +2515,7 @@ session.Wait(5 * time.Second)
25152515
> Under the hood `session.Wait` simply uses `Eventually`.
25162516
25172517

2518-
Since the signalling methods return the session you can chain calls together:
2518+
Since the signaling methods return the session you can chain calls together:
25192519

25202520
```go
25212521
session.Terminate().Wait()
@@ -2819,7 +2819,7 @@ Expect(actual).To(MatchAllFields(Fields{
28192819

28202820
## `gmeasure`: Benchmarking Code
28212821

2822-
`gmeasure` provides support for measuring and recording benchmarks of your code and tests. It can be used as a simple standalone benchmarking framework, or as part of your code's test suite. `gmeasure` integrates cleanly with Ginkgo V2 to enable rich benchmarking of code alognside your tests.
2822+
`gmeasure` provides support for measuring and recording benchmarks of your code and tests. It can be used as a simple standalone benchmarking framework, or as part of your code's test suite. `gmeasure` integrates cleanly with Ginkgo V2 to enable rich benchmarking of code alongside your tests.
28232823

28242824
### A Mental Model for `gmeasure`
28252825

@@ -3158,7 +3158,7 @@ This simple connection point ensures that the output is appropriately formatted
31583158

31593159
### Caching Experiments
31603160

3161-
`gmeasure` supports caching experiments to local disk. Experiments can be stored and retreived from the cache by name and version number. Caching allows you to skip rerunning expensive experiments and versioned caching allows you to bust the cache by incrementing the version number. Under the hood, the cache is simply a set of files in a directory. Each file contains a JSON encoded header with the experiment's name and version number followed by the JSON-encoded experiment. The various cache methods are documented over at [pkg.go.dev](https://pkg.go.dev/github.com/onsi/gomega/gmeasure#ExperimentCache).
3161+
`gmeasure` supports caching experiments to local disk. Experiments can be stored and retrieved from the cache by name and version number. Caching allows you to skip rerunning expensive experiments and versioned caching allows you to bust the cache by incrementing the version number. Under the hood, the cache is simply a set of files in a directory. Each file contains a JSON encoded header with the experiment's name and version number followed by the JSON-encoded experiment. The various cache methods are documented over at [pkg.go.dev](https://pkg.go.dev/github.com/onsi/gomega/gmeasure#ExperimentCache).
31623162

31633163
Using an `ExperimentCache` with Ginkgo takes a little bit of wiring. Here's an example:
31643164

@@ -3358,7 +3358,7 @@ results in one or more goroutines. The ordering of the goroutines does not
33583358
matter.
33593359

33603360
`HaveLeaked` always takes the built-in list of well-known good goroutines into
3361-
consideration and this list can neither be overriden nor disabled. Additional
3361+
consideration and this list can neither be overridden nor disabled. Additional
33623362
known non-leaky goroutines `NONLEAKY1`, ... can be passed to `HaveLeaks` either
33633363
in form of `GomegaMatcher`s or in shorthand notation:
33643364

@@ -3435,11 +3435,11 @@ goroutine(s) as non-leaky. `IgnoringGoroutines` compares goroutines by their
34353435
Eventually(Goroutines).ShouldNot(HaveLeaked(IgnoringInBacktrace(FNAME)))
34363436
```
34373437

3438-
`IgnoringInBacktrace` succeeds if `ACTUAL` contains a groutine where `FNAME` is
3438+
`IgnoringInBacktrace` succeeds if `ACTUAL` contains a goroutine where `FNAME` is
34393439
contained anywhere within its call stack (backtrace), causing `HaveLeaked` to
34403440
filter out the matched goroutine as non-leaky. Please note that
34413441
`IgnoringInBacktrace` uses a (somewhat lazy) `strings.Contains` to check for any
3442-
occurence of `FNAME` in backtraces.
3442+
occurrence of `FNAME` in backtraces.
34433443

34443444
`ACTUAL` must be an array or slice of `Goroutine`s.
34453445

@@ -3450,7 +3450,7 @@ Eventually(Goroutines).ShouldNot(HaveLeaked(IgnoringCreator(CREATORNAME)))
34503450
```
34513451

34523452
In its most basic form, `IgnoringCreator` succeeds if `ACTUAL` contains a
3453-
groutine where the name of the function creating the goroutine matches
3453+
goroutine where the name of the function creating the goroutine matches
34543454
`CREATORNAME`, causing `HaveLeaked` to filter out the matched goroutine(s) as
34553455
non-leaky. `IgnoringCreator` uses `==` for comparing the creator function name.
34563456

@@ -3497,7 +3497,7 @@ names of the topmost functions on their stacks (backtraces):
34973497
- `testing.RunTests [chan receive]`,
34983498
- `testing.(*T).Run [chan receive]`,
34993499
- and `testing.(*T).Parallel [chan receive]`.
3500-
- the [Ginko testing framework](https://onsi.github.io/ginkgo/):
3500+
- the [Ginkgo testing framework](https://onsi.github.io/ginkgo/):
35013501
- `github.com/onsi/ginkgo/v2/internal.(*Suite).runNode` (including anonymous
35023502
inner functions),
35033503
- the anonymous inner functions of

gcustom/make_matcher.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func ParseTemplate(templ string) (*template.Template, error) {
4141
/*
4242
MakeMatcher builds a Gomega-compatible matcher from a function (the matchFunc).
4343
44-
matchFunc must return (bool, error) and take a single argument. If you want to perform type-checking yourself pass in a matchFunc of type `func(actual any) (bool, error)`. If you want to only operate on a specific type, pass in `func(actual DesiredType) (bool, error)`; MakeMatcher will take care of checking typues for you and notifying the user if they use the matcher with an invalid type.
44+
matchFunc must return (bool, error) and take a single argument. If you want to perform type-checking yourself pass in a matchFunc of type `func(actual any) (bool, error)`. If you want to only operate on a specific type, pass in `func(actual DesiredType) (bool, error)`; MakeMatcher will take care of checking types for you and notifying the user if they use the matcher with an invalid type.
4545
4646
MakeMatcher(matchFunc) builds a matcher with generic failure messages that look like:
4747
@@ -68,7 +68,7 @@ where templateString is a string that is compiled by WithTemplate into a matcher
6868
6969
template, err = gcustom.ParseTemplate(templateString) //use gcustom's ParseTemplate to get some additional functions mixed in
7070
matcher := MakeMatcher(matchFunc, template)
71-
matcher := MakeMatcher(matchFunc).WithPrcompiled(template)
71+
matcher := MakeMatcher(matchFunc).WithPrecompiled(template)
7272
7373
When a simple message string is provided the positive failure message will look like:
7474
@@ -161,25 +161,25 @@ Templates are provided the following variables and functions:
161161
{{.To}} - is set to "to" if this is a positive failure message and "not to" if this is a negated failure message
162162
{{.Actual}} - the actual passed in to the matcher
163163
{{.FormattedActual}} - a string representing the formatted actual. This can be multiple lines and is always generated with an indentation of 1
164-
{{format <object> <optional-indentaiton}} - a function that allows you to use Gomega's default formatting from within the template. The passed-in <object> is formatted and <optional-indentation> can be set to an integer to control indentation.
164+
{{format <object> <optional-indentation}} - a function that allows you to use Gomega's default formatting from within the template. The passed-in <object> is formatted and <optional-indentation> can be set to an integer to control indentation.
165165
166166
In addition, you can provide custom data to the template by calling WithTemplate(templateString, data) (where data can be anything). This is provided to the template as {{.Data}}.
167167
168168
Here's a simple example of all these pieces working together:
169169
170170
func HaveWidget(widget Widget) OmegaMatcher {
171171
return MakeMatcher(func(machine Machine) (bool, error) {
172-
return maching.HasWidget(widget), nil
172+
return machine.HasWidget(widget), nil
173173
}).WithTemplate("Expected:\n{{.FormattedActual}}\n{{.To}} have widget named {{.Data.Name}}:\n{{format .Data 1}}", widget)
174174
}
175175
176-
Expect(maching).To(HaveWidget(Widget{Name: "sprocket", Version: 2}))
176+
Expect(machine).To(HaveWidget(Widget{Name: "sprocket", Version: 2}))
177177
178178
Would generate a failure message that looks like:
179179
180180
Expected:
181181
<formatted machine>
182-
to have widget named sprocker:
182+
to have widget named sprocket:
183183
<formatted sprocket>
184184
*/
185185
func (c CustomGomegaMatcher) WithTemplate(templ string, data ...any) CustomGomegaMatcher {
@@ -205,7 +205,6 @@ WithTemplateData() returns a CustomGomegaMatcher configured to provide it's temp
205205
206206
MakeMatcher(matchFunc).WithTemplate(templateString, data)
207207
MakeMatcher(matchFunc).WithTemplate(templateString).WithTemplateData(data)
208-
209208
*/
210209
func (c CustomGomegaMatcher) WithTemplateData(data any) CustomGomegaMatcher {
211210
c.templateData = data

0 commit comments

Comments
 (0)