Fork me on GitHub
#clojure-spec
<
2018-05-04
>
jstew00:05:19

What do I use if I just want to ensure that a fn returns a string or something?

(s/fdef ::string-fn
        :args (s/cat)
        :ret string?)
(s/explain ::string-fn #(identity "string"))

jstew00:05:36

It wants me to add test.check as a dependency

Alex Miller (Clojure team)01:05:18

I think you’re mixing syntax here and that’s leading you down a path trying to gen anonymous functions with check

Alex Miller (Clojure team)01:05:49

(s/def ::string-fn (s/fspec :args (s/cat) ret string?)) would be better for this

Alex Miller (Clojure team)01:05:52

When function specs are validated they use the generator for the anonymous function to invoke the function being validated and verify the outputs. Using that generator requires test.check

jstew10:05:00

Ah hah. That makes sense. Thank you, Alex.