Skip to content

Commit fde643d

Browse files
Apply suggestions from code review
Co-authored-by: Emil Hvitfeldt <[email protected]>
1 parent aef39b7 commit fde643d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

vignettes/custom-expectation.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ An expectation has three main parts, as illustrated by `expect_length()`:
2424

2525
```{r}
2626
expect_length <- function(object, n) {
27-
# 1. Capture object and label
27+
# 1. Capture object and its label
2828
act <- quasi_label(rlang::enquo(object), arg = "object")
2929
3030
# 2. Fail when expectations aren't met
@@ -39,7 +39,7 @@ expect_length <- function(object, n) {
3939
}
4040
```
4141

42-
The first step in any expectation is to use `quasi_label()` to capture a "labelled value", i.e. an list that contains both the value (`$val`) for testing and a label (`$lab`) for messaging. This is a pattern that exists for fairly esoteric reasons; you don't need to understand, just copy and paste it 🙂.
42+
The first step in any expectation is to use `quasi_label()` to capture a "labelled value", i.e. a list that contains both the value (`$val`) for testing and a label (`$lab`) for messaging. This is a pattern that exists for fairly esoteric reasons; you don't need to understand, just copy and paste it 🙂.
4343

4444
Next you need to check each way that `object` could be broken. In most cases, it's easier to check for problems one by one, using early returns to `fail()` when any expectation is violated as that makes it easier to write failure messages. It's good practice to state both what the object is and what you expected in your failures.
4545

@@ -62,7 +62,7 @@ Once you've written your expectation, you need to test it, and luckily testthat
6262
* `expect_failure()` checks that your expectation emits exactly one failure and zero successes.
6363
* `expect_failure_snapshot()` captures the failure message in a snapshot, making it easier to review if it's useful or not.
6464

65-
The first two expectations are particularly important because they ensure that your expectation reports the correct number of succeses and failures to the user.
65+
The first two expectations are particularly important because they ensure that your expectation reports the correct number of successes and failures to the user.
6666

6767
```{r}
6868
test_that("expect_length works as expected", {
@@ -79,7 +79,7 @@ test_that("expect_length gives useful feedback", {
7979

8080
## Examples
8181

82-
The following sections show you a few more variations, losely based on existing testthat expectations.
82+
The following sections show you a few more variations, loosely based on existing testthat expectations.
8383

8484
### `expect_vector_length()`
8585

0 commit comments

Comments
 (0)