Fork me on GitHub

does anyone know whether there’s some “clojure.spec cookbook” ?


(i.e. a collection of spec examples / community reviewed)

Geoffrey Gaillard11:04:49

Hello ! I have a set of keywords like (def ks #{::email ::password}) and I would like to build a spec from it, like

(s/def ::cred 
  (s/keys :req-un (into [] ks)))
But s/keys and s/def are macros so (into [] ks) is not evaluated… So I tried
(s/def ::cred 
  `(s/keys :req-un [[email protected]]))
But the inner part seems to not be expanded and passed "as is" to s/def. I have a feeling telling me that I'm doing something wrong here. Is it sane ? Is there a way to expand the body before s/def is called ?


You have to write your own macro

Geoffrey Gaillard11:04:49

A one that wrap s/def and s/keys ?

Geoffrey Gaillard11:04:26

Ah ! I get it ! Sorry for that 😕 Thank you !


Hi! Sorry for dumb question, but how i can run my spec tests as unit tests using clojure.test? My goal is to run tests in some CI tool using lein test.


@mike1452 write a regular test that calls spec and asserts about the response


Looks plausible


hello all, having a little trouble getting up and running with clojure.spec in clojurescript have these dependencies in my project.clj

[  [org.clojure/clojure "1.8.0"]
                 [org.clojure/clojurescript "1.9.494"]
                 [org.clojure/core.async "0.2.391"]
                 [org.clojure/test.check “0.9.0”] ]
and my namespace looks like
(ns foo.core
  (:require [cljs.spec :as s]
              [clojure.test.check :as tc]
              [clojure.test.check.generators :as gen]
              [ :as prop :include-macros true]))


with all that the following doesnt work it throws an error

(s/def ::node
    :leaf int?
    :branch (s/coll-of ::node :min-count 1 :max-count 2)))

(js/console.log (s/exercise ::node))


let me know if you can spot the error, much appriciate


tldr; the generator doesnt work which works in clj and does not work in cljs, not sure why or what im missing