Fork me on GitHub
#clojure-spec
<
2017-10-24
>
msolli08:10:51

Where is a good place to put (test/instrument) so that all my spec’ed functions are instrumented in dev? I have a fairly standard Luminus-based webapp.

ikitommi11:10:39

spec parsing is the new black 😉

stathissideris11:10:22

@ikitommi do you think we could use spec to parse spec forms or would reality collapse under the weight of self-reference? 😄

stathissideris12:10:50

way ahead of us 🙂

ikitommi12:10:24

but even when the spec-of-specs ships, we still need to utilities to do something with the parsed data, e.g. collect keys out of (s/merge ::a-map ::another-map), spec-tools is one bin collecting this kind of stuff. And there are many others.

taylor14:10:14

I’m curious about this too

jeaye15:10:58

I'm just using re-frame, not Luminus, but it's in my-app.core behind a macro.

jeaye15:10:22

That'll do the trick, allowing you to specify bits in your leiningen profiles and then conditionally bring in code by reading the profile using environ in a macro.

taylor15:10:46

thanks, the only caveat is that any namespaces you want to instrument must have already been loaded before that’s called, right?

jeaye15:10:55

That's right.

jeaye15:10:09

I don't think you can get around that though.

jeaye15:10:04

Our my-app.core requires every model ns we have. Our my-app.core-views requires every view ns we have, as well as requiring my-app.core (so view code isn't needed for unit testing).

taylor15:10:07

I wouldn’t imagine so, was just curious what other people’s approaches to that might be. I was thinking another approach would be to just put the (conditional) instrument calls at the bottom of each spec’d namespace

jeaye15:10:49

Hm, that would be every single ns for us, which seems less manageable. Sounds like it would work though, if that's your preference.

msolli18:10:40

Thanks, @U4986ECDQ, seems like a reasonable solution. Those are some handy macros! :thumbsup:

tony.kay15:10:11

I have a project where I use tools-ns to reload code. If I don’t carefully set refresh dirs then suddenly defn will start causing spec failures…as in defn- doesn’t conform to spec. Is this a known issue? Narrowing refresh dirs seems to fix it.