Skip to content

Commit

Permalink
prep for 2.0.157
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Jan 26, 2022
1 parent bd8438e commit fdf73d8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

Only accretive/fixative changes will be made from now on.

* 2.0.157 -- 2022-01-25
* Fix a small regression in how classes are treated when used as predicates in `expect`.

* 2.0.156 -- 2022-01-19
* 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.
* 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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A `clojure.test`-compatible version of the [classic Expectations testing library

## Where?

[![Clojars Project](https://clojars.org/com.github.seancorfield/expectations/latest-version.svg)](https://clojars.org/com.github.seancorfield/expectations) [![cljdoc badge](https://cljdoc.org/badge/com.github.seancorfield/expectations?2.0.156)](https://cljdoc.org/d/com.github.seancorfield/expectations/CURRENT)
[![Clojars Project](https://clojars.org/com.github.seancorfield/expectations/latest-version.svg)](https://clojars.org/com.github.seancorfield/expectations) [![cljdoc badge](https://cljdoc.org/badge/com.github.seancorfield/expectations?2.0.157)](https://cljdoc.org/d/com.github.seancorfield/expectations/CURRENT)

Try it out:

Expand Down
2 changes: 1 addition & 1 deletion doc/getting-started-cljs.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Your `deps.edn` should include this information:

```clojure
{:aliases {:cljs-runner
{:extra-deps {com.github.seancorfield/expectations {:mvn/version "2.0.156"},
{:extra-deps {com.github.seancorfield/expectations {:mvn/version "2.0.157"},
olical/cljs-test-runner {:mvn/version "3.7.0"},
pjstadig/humane-test-output {:mvn/version "0.10.0"}},
:extra-paths ["src" "test" "cljs-test-runner-out/gen"],
Expand Down
8 changes: 4 additions & 4 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ You can add `expectations.clojure.test` to your project with either:

```clojure
;; add this to :extra-deps under a :test alias:
com.github.seancorfield/expectations {:mvn/version "2.0.156"}
com.github.seancorfield/expectations {:mvn/version "2.0.157"}
```
for `deps.edn` or:

```clojure
;; add this to :dev-dependencies (Leiningen)
[com.github.seancorfield/expectations "2.0.156"]
[com.github.seancorfield/expectations "2.0.157"]
;; or add this to :dependencies (Boot)
[com.github.seancorfield/expectations "2.0.156" :scope "test"]
[com.github.seancorfield/expectations "2.0.157" :scope "test"]
```
for `project.clj` or `build.boot`.

Expand Down Expand Up @@ -186,7 +186,7 @@ Of course, you can also update the `:test` alias to add those new options into `
{:test
{:extra-paths ["test"]
:extra-deps
{com.github.seancorfield/expectations {:mvn/version "2.0.156"}
{com.github.seancorfield/expectations {:mvn/version "2.0.157"}
;; assumes Clojure CLI 1.10.3.933 or later:
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "48c3c67"}}
Expand Down
6 changes: 6 additions & 0 deletions src/expectations/clojure/test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@
#?(:clj java.util.regex.Pattern
:cljs (type #"regex")))
(some? (re-find e# a#))
#?(:clj (and (class? e#) (class? a#))
:cljs false) ; maybe figure this out later
(isa? a# e#) ; (expect parent child)
#?(:clj (class? e#)
:cljs false) ; maybe figure this out later
(instance? e# a#) ; (expect klazz object)
:else
(= e# a#))
humane?# (and humane-test-output? (not (fn? e#)) (not ~conform?))]
Expand Down
4 changes: 2 additions & 2 deletions test/expectations/clojure/test_macros.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
(with-redefs [do-report (sut/all-report results#)]
~expectation)
(t/is (some (fn [pass#]
(~success (:actual pass#)))
(:pass @results#)))))
(~success (:actual pass#)))
(:pass @results#)))))
18 changes: 15 additions & 3 deletions test/expectations/clojure/test_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

#?(:clj [clojure.test :refer [deftest is do-report testing]]
:cljs [cljs.test :include-macros true
:refer [do-report assert-expr]
:refer [do-report assert-expr]
:refer-macros [deftest is testing assert-expr
use-fixtures]])
use-fixtures]])
#?(:cljs [cljs.spec.alpha :as s])
#?(:cljs [expectations.clojure.test-spec])
#?(:clj [expectations.clojure.test :refer
Expand Down Expand Up @@ -59,13 +59,25 @@
;; TODO: fails because regexes never compare equal to themselves!
#_(is-not' (sut/expect #"fool" "It's foobar!") (not (re-find #"fool" "It's foobar!"))))

#?(:clj (def get-ex-message (or (resolve 'clojure.core/ex-message)
(fn [^Throwable t] (.getMessage t))))
:cljs (def get-ex-message ex-message))

#?(:clj (deftest exception-test
(passes (sut/expect ArithmeticException (/ 12 0))
(fn [ex]
(let [t (Throwable->map ex)]
(and (= "Divide by zero" (-> t :cause))
(or (= 'java.lang.ArithmeticException (-> t :via first :type))
(= java.lang.ArithmeticException (-> t :via first :type))))))))
(= java.lang.ArithmeticException (-> t :via first :type)))))))
(passes (sut/expect Exception (/ 12 0))
(fn [ex]
(let [t (Throwable->map ex)]
(and (= "Divide by zero" (-> t :cause))
(or (= 'java.lang.ArithmeticException (-> t :via first :type))
(= java.lang.ArithmeticException (-> t :via first :type)))))))
(is (sut/expect (more-> ArithmeticException type #"Divide by zero" get-ex-message) (/ 12 0)))
(is (sut/expect (more-> Exception type #"Divide by zero" get-ex-message) (/ 12 0))))

:cljs (deftest cljs-exception-test
(passes (sut/expect js/Error (throw (ex-info "foo" {})))
Expand Down

0 comments on commit fdf73d8

Please sign in to comment.