Skip to content

Instantly share code, notes, and snippets.

@CraZySacX
Created October 15, 2014 20:47
Show Gist options
  • Save CraZySacX/cb5c5d8d522a80b778aa to your computer and use it in GitHub Desktop.
Save CraZySacX/cb5c5d8d522a80b778aa to your computer and use it in GitHub Desktop.
Evaluating macro arguments
(def post-cfg {:ctx "/account POST"
:dba :start
:reqfn (as-admin (account-post))
:expected-status 200
:expected-message :localized/account-created})
(defmacro edn-req [{:keys [ctx dba reqfn sep
expected-status expected-message]
:or {sep true}}]
`(context
~ctx
(before-all (start-stop-datomic ~dba))
(after-all (if ~sep (println)))
(with-all ar# ~reqfn)))
; THIS DOES NOT WORK
(edn-req post-cfg)
; THIS WORKS
(edn-req {:ctx "/account POST"
:dba :start
:reqfn (as-admin (account-post))
:expected-status 200
:expected-message :localized/account-created})
@ckirkendall
Copy link

(def post-cfg {:ctx              "/account POST"
               :dba              :start
               :reqfn            (as-admin (account-post))
               :expected-status  200
               :expected-message :localized/account-created})

(defmacro edn-req [mp]
  `(let [{:keys [ctx dba reqfn sep
                           expected-status expected-message]
                    :or   {sep true}} mp]
     (context
       ctx
       (before-all (start-stop-datomic dba))
       (after-all (if sep (println)))
       (with-all ar# reqfn))))

; THIS DOES NOT WORK
(edn-req post-cfg)

; THIS WORKS
(edn-req {:ctx              "/account POST"
          :dba              :start
          :reqfn            (as-admin (account-post))
          :expected-status  200
          :expected-message :localized/account-created})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment