One of the examples in the clojure.spec Guide is a simple option-parsing spec:
(require \'[clojure.spec :as s])
(s/def ::config
(s/* (s/cat :prop string?
This question demonstrates an important distinction between specs used within an application and specs used to test the application.
Specs used within the app to conform or validate input — like :example.core/config
here — are part of the application code. They may be in the same file where they are used or in a separate file. In the latter case, the application code must :require
the specs, just like any other code.
Specs used as tests are loaded after the code they specify. These are your fdef
s and generators. You can put these in a separate namespace from the code — even in a separate directory, not packaged with your application — and they will :require
the code.
It's possible you have some predicates or utility functions that are used by both kinds of specs. These would go in a separate namespace all of their own.