Skip to content

Instantly share code, notes, and snippets.

@lenny
Last active January 18, 2017 22:00
Show Gist options
  • Save lenny/8197332758005dd71398dae684fcdb74 to your computer and use it in GitHub Desktop.
Save lenny/8197332758005dd71398dae684fcdb74 to your computer and use it in GitHub Desktop.
Snippet showing clojure.spec instrumentation with stubbing through deftest
(defn assert-valid [spec-check]
(let [failure (-> spec-check first :failure)]
(is (nil? failure))))
(deftest manifest
(let [find-spec (s/fspec :args (s/cat :id ::submission-directory/id)
:ret (s/or :found ::submission-directory/submission-directory :not-found nil?))]
(stest/instrument ['submissions-svr.db.submission-directories/find `submission/manifest-files]
{:spec {'submissions-svr.db.submission-directories/find find-spec}
:stub #{'submissions-svr.db.submission-directories/find `submission/manifest-files}})
(assert-valid (stest/check `submission/manifest {:clojure.spec.test.check/opts {:num-tests 50}}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment