Welcome! Please see the About page for a little more info on how this works.

0 votes
in Spec by

I would like to extend issue https://clojure.atlassian.net/browse/CLJ-2648 by stating that generate/valid?/exercise all dont work for any schema spec with a nested schema spec on it.

(s/def :another-entity/id uuid?)
(s/def :another-entity/some-attr int?)
(s/def ::another-entity (s/schema [:another-entity/id :another-entity/some-attr]))

(s/def :entity/id uuid?)
(s/def :entity/another-attr string?)
(s/def :entity/ref ::another-entity)
(s/def ::complex-entity (s/schema [:entity/id :entity/another-attr :entity/ref]))

(s/valid? ::complex-entity {:entity/id (random-uuid)
                            :entity/another-attr "oi"})
;;=> true
(s/valid? ::complex-entity {:entity/id (random-uuid)
                            :entity/another-attr "oi"
                            :entity/ref #:another-entity{:id (random-uuid)}})
;;=> Execution error (IllegalArgumentException) at clojure.alpha.spec.protocols/eval1960$fn$G (protocols.clj:11).
;    No implementation of method: :conform* of protocol: #'clojure.alpha.spec.protocols/Spec found for class: clojure.lang.Keyword

(generators/generate (s/gen ::complex-entity))
;;=> Execution error (IllegalArgumentException) at clojure.alpha.spec.protocols/eval1960$fn$G (protocols.clj:11).
;    No implementation of method: :conform* of protocol: #'clojure.alpha.spec.protocols/Spec found for class: clojure.lang.Keyword

Thanks :)

Please log in or register to answer this question.

...