Fork me on GitHub
#clojure-spec
<
2019-01-30
>
Josip Gracin08:01:20

Hi! clojure.spec.test.alpha/check silently ignores symbols which are not "checkable". This seems counter-intuitive to me because I'd expect it to fail when I call check on a symbol and the symbol does not have an associated spec (e.g. it is misspelled).

Josip Gracin08:01:47

the definition of check looks like this:

Josip Gracin08:01:49

(defn check ([] (check (checkable-syms))) ([sym-or-syms] (check sym-or-syms nil)) ([sym-or-syms opts] (->> (collectionize sym-or-syms) (filter (checkable-syms opts)) (pmap #(check-1 (sym->check-map %) opts)))))

Josip Gracin08:01:18

it seems to me that the (filter (checkable-syms opts)) might better go to the no-arg variant

Josip Gracin08:01:45

does this make sense?

mping15:01:41

Hi, is there any good way to xform spec’s :problems into something that could make sense for a human over a json api?

bbrinck16:01:15

I suppose it depends on how technical the user is, but you could potentially use Expound here.

bbrinck16:01:24

The default options might be too noisy (they include the specs), but this can be changed easily. You can also customize the messages in some cases. Let me know if you want help with configuring expound or just need some sample code for your use case.

bbrinck16:01:14

Phrase is another option

mping16:01:59

tks, I basically want to convert the spec’s :problems into something more tractable for a human

mping16:01:43

it seems that i’d have to change *explain-out* right?

bbrinck16:01:23

Yep, that’s what Expound does :)

bbrinck16:01:02

You can just replace explain-out with the printer provided by Expound

misha23:01:56

is there a rationalization why aliased specs can't be overwritten in spec1?

(s/def :user/foo string?)
(s/def :user/bar :user/foo) ;;alias
(s/exercise :user/bar 1 {:user/bar #(s/gen #{"quux"})}) ;;=> (["" ""])
(s/exercise :user/bar 1 {:user/foo #(s/gen #{"quux"})}) ;;=> (["quux" "quux"])

(s/def :user/bar string?) ;;not alias
(s/exercise :user/bar 1 {:user/bar #(s/gen #{"quux"})}) ;;=> (["quux" "quux"])
Can I somehow decouple gen-override call site from the knowledge of spec (not) being an alias?

misha23:01:09

Sticking generator on the spec at s/def time works, but I'd like to avoid nailing generator to spec.

misha23:01:36

Override for alias with custom generator works though:

(s/def :user/foo string?)
(s/def :user/bar (s/with-gen :user/foo #(s/gen #{"bar"})))
(s/exercise :user/bar 1)
=> (["bar" "bar"])
(s/exercise :user/bar 1 {:user/bar #(s/gen #{"quux"})})
=> (["quux" "quux"])

Alex Miller (Clojure team)23:01:25

there’s a ticket for it

misha23:01:55

should I wait for spec2? or spec 1 gets things fixed too?

Alex Miller (Clojure team)23:01:54

I think I actually fixed it already in spec 2, but I haven’t tested it explicitly

Alex Miller (Clojure team)23:01:00

but no release of spec 2 yet

misha23:01:41

do you have any guestimate for closest spec2 release?