Skip to content

Instantly share code, notes, and snippets.

@alexanderkiel
Created May 31, 2016 15:55
Show Gist options
  • Save alexanderkiel/931387c7a86c1879b2267ad064067af7 to your computer and use it in GitHub Desktop.
Save alexanderkiel/931387c7a86c1879b2267ad064067af7 to your computer and use it in GitHub Desktop.
Integration of check-var in clojure.test/is
(defmethod assert-expr 'conform-var? [msg form]
;; Test if the var v conforms to it's spec.
(let [args (rest form)]
`(let [result# (clojure.spec.test/check-var ~@args)]
(if (true? (:result result#))
(do-report {:type :pass :message ~msg
:expected '~form :actual result#})
(do-report {:type :fail :message ~msg
:expected '~form :actual result#}))
result#)))
@alexanderkiel
Copy link
Author

You can use conform-var? this way:

(deftest my-test
  (is (conform-var? #'my-ns/var)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment