Skip to content

Commit

Permalink
Add PanicWith().
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc authored and williammartin committed May 6, 2020
1 parent 3eb68db commit 8cbb0d3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,16 @@ Here are some examples:

succeeds if `ACTUAL` is a function that, when invoked, panics. `ACTUAL` must be a function that takes no arguments and returns no result -- any other type for `ACTUAL` is an error.

#### PanicWith()

Ω(ACTUAL).Should(PanicWith(VALUE))

succeeds if `ACTUAL` is a function that, when invoked, panics with a value of `VALUE`. `ACTUAL` must be a function that takes no arguments and returns no result -- any other type for `ACTUAL` is an error.

By default `PanicWith()` uses the `Equal()` matcher under the hood to assert equality between `ACTUAL`'s panic value and `VALUE`. You can change this, however, by passing `PanicWith` a `GomegaMatcher`. For example, to check that the panic value matches a regular expression:

Ω(func() { panic("FooBarBaz") }).Should(PanicWith(MatchRegexp(`.+Baz$`)))

### Composing Matchers

You may form larger matcher expressions using the following operators: `And()`, `Or()`, `Not()` and `WithTransform()`.
Expand Down

0 comments on commit 8cbb0d3

Please sign in to comment.