Clojurians
#kaocha
<
2018-12-05
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

plexus11:12:01

@miikka not at the moment, no. It's not something I've looked into so far. From a quick look at the documentation it seems like running check returns a map with information about the success/failure? It doesn't seem like there's already something in place to connect this with clojure.test. A custom assertion would do the trick.

plexus11:12:25

This is untested pseudocode but it should give you an idea

(deftest checking-vars-test
  (is (spec/check? #'foo))
  (is (spec/check? #'bar)))

(defmethod clojure.test/assert-expr 'spec/check? [msg form]
  (let [v (second form)]
    `(let [result# (clojure.spec.test.alpha/check v)]
       (if (true? (:result result#))
         (clojure.test/do-report {:type :pass})
         (clojure.test/do-report {:type :fail, :expected ~form, :actual result#}))))

plexus11:12:54

Feel free to make a ticket about this so this doesn't get lost. This might make sense as a separate mini library that implements a number of spec-based assertions.