Skip to content

Commit 86fda3a

Browse files
miparnisarionsi
authored andcommitted
fix grammar
1 parent 7470c9e commit 86fda3a

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

docs/index.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,7 @@ Ginkgo will emit a warning if it detects this.
694694

695695
#### Avoid Spec Pollution: Don't Initialize Variables in Container Nodes
696696

697-
We've covered this already but it bears repeating: **"Declare in container nodes, initialize in setup nodes"**. Since container nodes are only invoked once during the tree construction phase you should declare closure variables in container nodes but always initialize them in setup nodes. The following is
698-
invalid can potentially infuriating to debug:
697+
We've covered this already but it bears repeating: **"Declare in container nodes, initialize in setup nodes"**. Since container nodes are only invoked once during the tree construction phase you should declare closure variables in container nodes but always initialize them in setup nodes. The following is invalid and can potentially be infuriating to debug:
699698

700699
```go
701700
/* === INVALID === */
@@ -1010,7 +1009,7 @@ Describe("Reporting book weight", func() {
10101009

10111010
That's better. The specs will now clean up after themselves correctly.
10121011

1013-
One quick note before we move on, you may have caught that `book.HumanReadableWeight()` returns _two_ values - a `weight` string and an `error`. This is common pattern and Gomega has first class support for it. The assertion:
1012+
One quick note before we move on, you may have caught that `book.HumanReadableWeight()` returns _two_ values - a `weight` string and an `error`. This is a common pattern and Gomega has first class support for it. The assertion:
10141013

10151014
```go
10161015
Expect(book.HumanReadableWeight()).To(Equal("17.6oz"))
@@ -1020,7 +1019,7 @@ is actually making two assertions under the hood. That the first value returned
10201019

10211020
#### Cleaning up our Cleanup code: DeferCleanup
10221021

1023-
Setup and cleanup patterns like the one above are common in Ginkgo suites. While powerful, however, `AfterEach` nodes have a tendency to separate cleanup code from setup code. We had to create an `originalWeightUnits` closure variable to keep track of the original environment variable in the `BeforeEach` and pass it to the `AfterEach` - this feels noisy and potential error-prone.
1022+
Setup and cleanup patterns like the one above are common in Ginkgo suites. While powerful, however, `AfterEach` nodes tend to separate cleanup code from setup code. We had to create an `originalWeightUnits` closure variable to keep track of the original environment variable in the `BeforeEach` and pass it to the `AfterEach` - this feels noisy and potential error-prone.
10241023

10251024
Ginkgo provides the `DeferCleanup()` function to help solve for this usecase and bring spec setup closer to spec cleanup. Here's what our example looks like with `DeferCleanup()`:
10261025

@@ -1689,7 +1688,7 @@ DescribeTableSubtree("handling requests",
16891688
)
16901689
```
16911690

1692-
now the body function passed to the table is invoked during the Tree Construction Phase to generate a set of specs for each entry. Each body function is invoked within the context of a new container so that setup nodes will only run for the specs defined in the body function. As with `DescribeTable` this is simply synctactic sugar around Ginkgo's existing DSL. The above example is identical to:
1691+
now the body function passed to the table is invoked during the Tree Construction Phase to generate a set of specs for each entry. Each body function is invoked within the context of a new container so that setup nodes will only run for the specs defined in the body function. As with `DescribeTable` this is simply syntactic sugar around Ginkgo's existing DSL. The above example is identical to:
16931692

16941693
```go
16951694

@@ -1933,7 +1932,7 @@ Finally, if your specs need to _generate_ random numbers you can seed your pseud
19331932

19341933
### Spec Parallelization
19351934

1936-
As spec suites grow in size and complexity they have a tendency to get slower. Thankfully the vast majority of modern computers ship with multiple CPU cores. Ginkgo helps you use those cores to speed up your suites by running specs in parallel. This is _especially_ useful when running large, complex, and slow integration suites where the only means to speed things up is to embrace parallelism.
1935+
As spec suites grow in size and complexity they tend to get slower. Thankfully the vast majority of modern computers ship with multiple CPU cores. Ginkgo helps you use those cores to speed up your suites by running specs in parallel. This is _especially_ useful when running large, complex, and slow integration suites where the only means to speed things up is to embrace parallelism.
19371936

19381937
To run a Ginkgo suite in parallel you simply pass the `-p` flag to `ginkgo`:
19391938

@@ -2612,7 +2611,7 @@ To build on our example above, here are some label filter queries and their beha
26122611
| `ginkgo --label-filter="integration"` | Match any specs with the `integration` label |
26132612
| `ginkgo --label-filter="!slow"` | Avoid any specs labelled `slow` |
26142613
| `ginkgo --label-filter="network && !slow"` | Run specs labelled `network` that aren't `slow` |
2615-
| `ginkgo --label-filter=/library/` | Run specs with labels matching the regular expression `library` - this will match the three library-related specs in our example.
2614+
| `ginkgo --label-filter=/library/` | Run specs with labels matching the regular expression `library` - this will match the three library-related specs in our example. |
26162615

26172616
##### Label Sets
26182617

@@ -3453,7 +3452,7 @@ The two verbose settings are most helpful when debugging spec suites. They make
34533452

34543453
Very-verbose mode contains additional information over verbose mode. In particular, `-vv` timelines indicate when individual nodes start and end and also include the full failure descriptions for _every_ failure encountered by the spec. Verbose mode does not include the node start/end events (though this can be turned on with `--show-node-events`) and does not include detailed failure information for anything other than the first (primary) failure. (Additional/subsequent failures typically occur in clean-up nodes and are not as relevant as the primary failure that occurs in a subject or setup node).
34553454

3456-
When you [filter specs](#filtering-specs) using Ginkgo's various filtering mechanism Ginkgo usually emits a single cyan `S` for each skipped spec. If you run with the very-verbose setting, however, Ginkgo will emit the description and location information of every skipped spec. This can be useful if you need to debug your filter queries and can be paired with `--dry-run`.
3455+
When you [filter specs](#filtering-specs) using Ginkgo's various filtering mechanisms Ginkgo usually emits a single cyan `S` for each skipped spec. If you run with the very-verbose setting, however, Ginkgo will emit the description and location information of every skipped spec. This can be useful if you need to debug your filter queries and can be paired with `--dry-run`.
34573456

34583457
#### Other Settings
34593458
Here are a grab bag of other settings:
@@ -3647,7 +3646,7 @@ var _ = ReportAfterSuite("interruptible ReportAfterSuite", func(ctx SpecContext,
36473646

36483647
The closure passed to `ReportBeforeSuite` is called exactly once at the beginning of the suite before any `BeforeSuite` nodes or specs run have run. The closure passed to `ReportAfterSuite` is called exactly once at the end of the suite after any `AfterSuite` nodes have run.
36493648

3650-
Finally, and most importantly, when running in parallel both `ReportBeforeSuite` and `ReportAfterSuite` **only run on process #1**. Gingko guarantess that no other processes will start running their specs until after `ReportBeforeSuite` on process #1 has completed. Similarly, Ginkgo will only run `ReportAfterSuite` on process #1 after all other processes have finished and exited. Ginkgo provides a single `Report` that aggregates the `SpecReports` from all processes. This allows you to perform any custom suite reporting in one place after all specs have run and not have to worry about aggregating information across multiple parallel processes.
3649+
Finally, and most importantly, when running in parallel both `ReportBeforeSuite` and `ReportAfterSuite` **only run on process #1**. Gingko guarantees that no other processes will start running their specs until after `ReportBeforeSuite` on process #1 has completed. Similarly, Ginkgo will only run `ReportAfterSuite` on process #1 after all other processes have finished and exited. Ginkgo provides a single `Report` that aggregates the `SpecReports` from all processes. This allows you to perform any custom suite reporting in one place after all specs have run and not have to worry about aggregating information across multiple parallel processes.
36513650

36523651
Given all this, we can rewrite our invalid `ReportAfterEach` example from above into a valid `ReportAfterSuite` example:
36533652

@@ -4932,7 +4931,7 @@ here we've assumed the `client` can take and restore a snapshot of the database.
49324931

49334932
With this approach each parallel process has its own dedicated database so there is no chance for cross-spec pollution when running in parallel. Within each parallel process the dedicated database is cleared out between specs so there's no chance for spec pollution from one spec to the next.
49344933

4935-
This all works if you have the ability to spin up a local copy of the database. But there are times when you must rely on an external stateful singleton resource and need to test against it. We'll explore patterns for testing those next.
4934+
This all works if you can spin up a local copy of the database. But there are times when you must rely on an external stateful singleton resource and need to test against it. We'll explore patterns for testing those next.
49364935

49374936
#### Patterns for Testing against Singletons
49384937
There are times when your spec suite must run against a stateful shared singleton system. Perhaps it is simply too expensive to spin up multiple systems (e.g. each "system" is actually a memory-hungry cluster of distributed systems; or, perhaps, you are testing against a real-life instance of a service and can't spin up another instance).
@@ -5372,7 +5371,7 @@ Currently none of these decorators can be applied to container nodes.
53725371
53735372
## Ginkgo CLI Overview
53745373
5375-
This chapter provides a quick overview and tour of the Ginkgo CLI. For comprehensive details about all of the Ginkgo CLI's flags, run `ginkgo help`. To get information about Ginkgo's implicit `run` command (i.e. what you get when you just run `ginkgo`) run `ginkgo help run`.
5374+
This chapter provides a quick overview and tour of the Ginkgo CLI. For comprehensive details of Ginkgo CLI's flags, run `ginkgo help`. To get information about Ginkgo's implicit `run` command (i.e. what you get when you just run `ginkgo`) run `ginkgo help run`.
53765375
53775376
The Ginkgo CLI is the recommended and supported tool for running Ginkgo suites. While you _can_ run Ginkgo suites with `go test` you must use the CLI to run suites in parallel and to aggregate profiles. There are also a (small) number of `go test` flags that Ginkgo does not support - an error will be emitted if you attempt to use these (for example, `go test -count=N`, use `ginkgo -repeat=N` instead).
53785377
@@ -5497,7 +5496,7 @@ This generates an outline in a comma-separated-values (CSV) format. Column heade
54975496
54985497
Name,Text,Start,End,Spec,Focused,Pending,Labels
54995498
Describe,Book,124,973,false,false,false,""
5500-
BeforeEach,,217,507,false,false,false,""
5499+
BeforeEach,217,507,false,false,false,""
55015500
Describe,Categorizing book length,513,970,false,false,false,""
55025501
Context,With more than 300 pages,567,753,false,false,false,""
55035502
It,should be a novel,624,742,true,false,false,""
@@ -5629,6 +5628,6 @@ Set the `GINKGO_PRESERVE_CACHE` environment variable to `true` in order to
56295628
skip the `os.Getwd()` call. This may affect the reporter output.
56305629
56315630
### The ginkgolinter
5632-
The [ginkgolinter](https://github.com/nunnatsa/ginkgolinter) enforces several patterns of using ginkgo and gomega. It can run as an independent executable or as part of the [golangci-lint](https://golangci-lint.run/) linter. See the ginkgolinter [READMY](https://github.com/nunnatsa/ginkgolinter#readme) for more details.
5631+
The [ginkgolinter](https://github.com/nunnatsa/ginkgolinter) enforces several patterns of using ginkgo and gomega. It can run as an independent executable or as part of the [golangci-lint](https://golangci-lint.run/) linter. See the ginkgolinter [README](https://github.com/nunnatsa/ginkgolinter#readme) for more details.
56335632
56345633
{% endraw %}

0 commit comments

Comments
 (0)