Skip to content

Instantly share code, notes, and snippets.

@oliyh
Created June 19, 2014 16:14
Show Gist options
  • Save oliyh/5f0f84125c5352921726 to your computer and use it in GitHub Desktop.
Save oliyh/5f0f84125c5352921726 to your computer and use it in GitHub Desktop.
Failing test describing how interaction with middleware like wrap-params results in unexpected entries in the route-params map
(ns bidi.bidi-test
(:require [clojure.test :refer :all]
[bidi.bidi :refer :all]
[ring.mock.request :refer :all]))
(deftest route-params-hygiene-test
(testing "other request constraints"
(let [handler
(make-handler [["/blog/user/" :userid "/article"]
(fn [req] {:status 201 :body (:route-params req)})])]
(is handler)
(testing "specified params like userid make it into :route-params
but other params do not"
(is (= (handler (-> (request :put "/blog/user/8888/article")
(assoc :params {"foo" "bar"})))
{:status 201 :body {:userid "8888"}}))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment