Fork me on GitHub
#testing
<
2017-03-08
>
ejelome23:03:36

hello, how do you get the query parameter's value using ring.mock.request? for example, I have this resource route:

(defroutes app
  (ANY "/" []
       (resource :available-media-types ["text/html"]
                 :exists? (fn [context]
                            (= "wooji" (get-in context [:request :params "dog"])))
                 :handle-ok "You found a treasure!"
                 :handle-not-found "Nope! That's not the treasure")))
and here's the test:
(facts "about GET /?dog=wooji"
              (let [response (app (request :get "/" {:dog "wooji"}))]
                (fact "body: You found a treasure"
                      (:body response) => "You found a treasure!"))))
But it doesn't seem to work, the app handler is using the wrap-params (which I think is required to correct ring.mock.request capturing of parameters:
(def handler
  (-> app
      wrap-params))

ejelome23:03:47

If I type it directly to the browser, it works, but ring.mock.request seems like not being able to get it