Permalink
Browse files

Fixed '& more' destructuring bug and added test

  • Loading branch information...
1 parent 84a16ad commit 6c4e97627d97e8b74a0b695deeb396ddaf586006 @weavejester committed Jul 13, 2010
Showing with 17 additions and 7 deletions.
  1. +1 −1 src/compojure/core.clj
  2. +16 −6 test/compojure/test/core.clj
@@ -39,7 +39,7 @@
[request bindings body]
(let [[args [_ more]] (split-with #(not= % '&) bindings)]
`(let [{:strs ~(vec args)} (~request :params)
- ~@(if more [more `(dissoc (~request :params) ~@(map keyword args))])]
+ ~@(if more [more `(dissoc (~request :params) ~@(map str args))])]
~@body)))
(defmacro bind-request
@@ -13,17 +13,27 @@
(is (= x "bar"))
(is (= y "baz"))
nil)
- {:request-method :get
- :uri "/foo"
- :params {"x" "bar", "y" "baz"}}))
+ {:request-method :get
+ :uri "/foo"
+ :params {"x" "bar", "y" "baz"}}))
+
+ (testing "vector '& more' arguments"
+ ((GET "/:x" [x y & more]
+ (is (= x "foo"))
+ (is (= y "bar"))
+ (is (= more {"z" "baz"}))
+ nil)
+ {:request-method :get
+ :uri "/foo"
+ :params {"y" "bar", "z" "baz"}}))
(testing "map arguments"
((GET "/foo" {params :params}
(is (= (params {:x "a", :y "b"})))
nil)
- {:request-method :get
- :uri "/foo"
- :params {"x" "a", "y" "b"}})))
+ {:request-method :get
+ :uri "/foo"
+ :params {"x" "a", "y" "b"}})))
(deftest route-matching
(testing "_method parameter"

0 comments on commit 6c4e976

Please sign in to comment.