Instead of:
(app
[""] (fn [req] {:status 200 :header {...} :body}))
Ideally, I’d like to write something like:
(app
[""] {:page-name "index"})
and then use the :page-name to build my template. At the same time I can just assert that given a URL like "/" the expected page is called "index".
Is there a way to do this? Am I completely off track?
Thank you in advance
--
Giorgio Valoti
My intent is testing moustache routes in isolation from page generation. I thought about using a middleware solution but I was unsure about it: would it be a good / idiomatic use of middleware?
--
Giorgio Valoti
I think what you want here is to use a combination of ring-mock to
mock your requests, and something like clojure.contrib.mock or midje
to mock the functions your routes call.
For example:
(def handler
(app [""] index-handler))
(deftest test-routes
(expect [index-handler (times 1)]
(handler (request :get "/")))))
- James
Sounds like the perfect solution. Thank you, James!
Ciao
--
Giorgio Valoti