Skip to content

Instantly share code, notes, and snippets.

@danielribeiro
Forked from mybuddymichael/deftest*.clj
Created February 14, 2013 05:40
Show Gist options
  • Save danielribeiro/4950818 to your computer and use it in GitHub Desktop.
Save danielribeiro/4950818 to your computer and use it in GitHub Desktop.
Simple spec helper for clojure tests
(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