Skip to content

Commit 841651e

Browse files
committed
fix #26 by improving docs
1 parent ea6ec1e commit 841651e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Only accretive/fixative changes will be made from now on.
88

99
* 2.0.next in progress
10+
* Address [#26](https://github.com/clojure-expectations/clojure-test/issues/26) by adding an example combining `more->` and `more-of` around destructuring `ex-info` data.
1011
* Fix [#24](https://github.com/clojure-expectations/clojure-test/issues/24) by using a local (gensym) for the actual value in `more` and `more->` so it is only evaluated once.
1112
* Update `build-clj` to v0.6.7 and automate snapshot/release builds.
1213

doc/more.md

+15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Since the test value is threaded-first into the expressions, we can use `->` to
5555
(/ 1 0))
5656
```
5757

58+
See below for a more comprehensive example of exception testing that also uses `more-of`.
59+
5860
## `expect more-of`
5961

6062
Sometimes destructuring an (actual) test value is the easiest way to apply your expectations:
@@ -112,6 +114,19 @@ to `are` in `clojure.test` (but more powerful):
112114
Although this is more verbose for this basic example, remember that the
113115
`expected` value could also be a predicate function, a regex, a Spec, etc.
114116

117+
`more-of` can also be used with `more->` to provide succinct tests on Clojure's `ex-info` exceptions:
118+
119+
```clojure
120+
(defexpect ex-info-tests
121+
(expect (more-> clojure.lang.ExceptionInfo type
122+
(more-of {:keys [status responseCode]}
123+
409 status
124+
4001110 responseCode) ex-data)
125+
(throw (ex-info "boo" {:status 409 :responseCode 4001110}))))
126+
```
127+
128+
In this example, the exception is threaded into `type` and the predicate is a class, and it is also threaded into `ex-data` and the predicate is a `more-of` expression that destructures that data and matches parts of it.
129+
115130
# Further Reading
116131

117132
* [Getting Started](/doc/getting-started.md)

0 commit comments

Comments
 (0)