-
-
Save danielribeiro/4950818 to your computer and use it in GitHub Desktop.
Simple spec helper for clojure tests
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
(require 'clojure.test) | |
; Source: https://gist.github.com/mybuddymichael/4425558 | |
(defmacro spec | |
[name-string & body] | |
(let [name-symbol | |
(-> name-string | |
clojure.string/lower-case | |
(clojure.string/replace #"\W" "-") | |
(clojure.string/replace #"-+" "-") | |
(clojure.string/replace #"-$" "") | |
symbol)] | |
`(clojure.test/deftest ~name-symbol ~@body))) | |
; ignoring specs | |
(defmacro xspec [name-string & body]) | |
(macroexpand-1 '(spec "this is a test" (is true))) | |
;=> (clojure.test/deftest this-is-a-test (is true)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment