I've been writing quite a lot of tests recently, with clojure.test
I wrote a little macro to help.
It means you could replace this :
(require '[clojure.test :refer :all]
'[schema.core :as s])
(deftest my-test
(let [response ...]
(is (= (:status response) 200))
(is (= (count (get-in response [:headers "content-length"])) (count "Hello
World!")))
(is (= (count (get-in response [:headers "content-type"]))
"text/plain;charset=utf-8"))
(is (nil? (s/check s/Str (get-in response [:headers "content-type"]))))
(is (instance? java.nio.ByteBuffer response))
))
, with this :
(require '[clojure.test :refer :all]
'[schema.core :as s]
'[juxt.iota :refer [given]])
(deftest my-test
(given response
:status := 200
:headers :⊃ {"content-length" (count "Hello World!")
"content-type" "text/plain;charset=utf-8"}
[:headers "content-type"] :- s/Str
:body :instanceof java.nio.ByteBuffer))
, using various infix operators :
:=is equal to:!=isn't equal to:-conforms to schema:!-doesn't conform to
schema:?satifies predicate:!?doesn't satisfy predicate:#matches regex:!#doesn't
match regex:> or :⊃is superset of:!> or :⊅isn't superset of:< or :⊂is
subset of:!< or :⊄isn't subset of:instanceofis instance of:!instanceofisn't
instance of
It's hardly ground-breaking, but feel free to use it if you like.
https://github.com/juxt/iota
Regards,
Malcolm
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.