Fork me on GitHub
#clojure-spec
<
2018-02-20
>
roklenarcic09:02:57

Hm I have a spec that limits string length to be between 0 and 10 characters. As I ask generate to generate a larger sample size, it starts to throw that it failed to satisfy such-that. What's the best way to deal with that?

gfredericks13:02:32

you have to supply your own generator; (gen/map #(apply str %) (gen/vector gen/char-ascii {:max-elements 10})) or something like that

roklenarcic13:02:49

test.chuck has a cap-size function that works great for this

igosuki14:02:54

@misha faire enough, thanks for the heads up

gfredericks17:02:17

@roklenarcic strictly speaking that's capping the size parameter, not the size of the collection. But they probably happen to coincide in this case.