A question concerning multi-spec
: Suppose I have a spec similar to the one given in the clojure spec guide (ie. :event/event
), where different events contain a :event/type
key. How can I generate sample events of a particular type, for example :event/error
events? Or refer to the spec of a particular event somewhere (e.g. in a s/fdef
). What I've tried so far: If I replace the spec from the corresponding defmethod
call into a s/def
definition, I can obtain the generator for it and I get all the fields I expect but the :event/type
key will be a random keyword. Another hack was to generate events from :event/event
and then use s/and
+ predicate to only accepts events which have the correct type, but this "lacks elegance" 🙂
One might argue that it reflects poor design if one has to refer to particular type like this, but still it might be nice to know if & how this is possible :thinking_face:
I think something like what you describe is how most people are approaching it right now