This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-23
Channels
- # beginners (55)
- # boot (37)
- # braid-chat (1)
- # chestnut (3)
- # cider (4)
- # clara (22)
- # cljs-dev (54)
- # cljsrn (3)
- # clojure (114)
- # clojure-italy (12)
- # clojure-losangeles (3)
- # clojure-portugal (1)
- # clojure-russia (1)
- # clojure-spec (30)
- # clojure-uk (67)
- # clojure-ukraine (1)
- # clojurescript (101)
- # core-async (11)
- # cursive (6)
- # data-science (27)
- # datomic (8)
- # figwheel (3)
- # fulcro (59)
- # graphql (2)
- # hoplon (89)
- # jobs (3)
- # jobs-rus (1)
- # leiningen (3)
- # lumo (19)
- # off-topic (9)
- # om (48)
- # pedestal (2)
- # portkey (4)
- # protorepl (19)
- # re-frame (13)
- # reagent (38)
- # remote-jobs (1)
- # ring-swagger (4)
- # spacemacs (10)
- # specter (2)
Am I right in thinking that the generator for (s/keys :req [(or ::a ::b ::c)]) will always return a map with all keys? I think that will leave out potential edge cases when doing generative testing.
there is a pending enhancement to fix that
Question: I've got a spec which is a map-of string? to itself. It works, but sometimes the generator takes like 5 seconds or more to generate a single example. Is there a way I can limit the number of recursive generation it does?
Should have googled it first: https://clojure.github.io/clojure/branch-master/clojure.spec-api.html#clojure.spec/*recursion-limit*
Hey all 🙂
I’m getting errors when starting my repl: clojure.lang.ExceptionInfo: Unable to resolve spec: :app.spec/thing
I require my app.spec
namespace in my main namespace so I’m thinking it should be loaded before other namespaces depending on it.
@rod unfortunately not but I may have just found the issue
another namespace except core required app.spec
resulting in it (+ some others) being loaded before the spec namespace was loaded
I just realized that multi-specs use the raw data, not conformed data, for their multimethods. I didn't expect that, but now that I think about it, it seems it's the only way to avoid dependency issues. Is this expected, or am I doing something silly? To clarify what I'm talking about:
(s/def ::type (s/and (s/conformer keyword) keyword?))
(defmulti part-type :type)
(defmethod part-type "meta" [_]
...)
The defmethod has to be defined on "meta"
, not :meta
, because that's what the database returns and that's what the value is before conforming.that seems like the expected behavior to me
multi-spec chooses a spec based on the data
note that the multimethod does not need to be based on a keyword though, it can be an arbitrary function
Yes, after thinking about this for a moment, I realized that it would be unreasonable to expect anything different. And yet it surprised me, I grew used to thinking of conform
as a conversion layer between database representation (JSON in my case) and native Clojure data. I expect the "conversion" to happen first, before the method gets selected.
I think I read somewhere that s/conform
isn't really intended for this role, but I find it amazingly useful.
omg this is amazing: https://github.com/gfredericks/test.chuck#string-from-regex
Thanks for the tip @alexmiller!
@adamfrey not without re-registering it
@bbrinck autodoc is used to create the clojure docs and it has rudimentary support for including specs
there are also one (or maybe more) tools for creating diagrams representing specs
@alexmiller Thanks!