Last active
January 18, 2017 22:00
-
-
Save lenny/8197332758005dd71398dae684fcdb74 to your computer and use it in GitHub Desktop.
Snippet showing clojure.spec instrumentation with stubbing through deftest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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