Fork me on GitHub
#clojure-spec
<
2019-03-01
>
djtango12:03:33

is there a way to provide a generator to a spec you want to use at runtime for validation, but have test.check only as a dev/test dependency?

djtango12:03:54

can you augment a spec in the registry in a separate namespace?

gfredericks12:03:00

@djtango the whole point of spec's proxy namespace for generators is to allow that

gfredericks12:03:31

you reference/build the generator using that namespace, and as long as you don't use it, t.c isn't needed

djtango12:03:05

hmm I must be doing something wrong

gfredericks12:03:48

I think any function calls in that ns have to be delayed inside a (fn [] ...) so that they don't actually happen

gfredericks12:03:16

which is part of why the spec api requires you to supply a 0-arg-function-that-returns-a-generator

borkdude12:03:45

I’m using this feature a lot, but it took a trick to get the string-from-regex generator to be decoupled from production code… https://github.com/borkdude/speculative/blob/master/src/speculative/specs.cljc#L180

borkdude12:03:15

I could have moved this code to the test code and use a generator overrride