Permalink
Browse files

Keyword regex context test

  • Loading branch information...
1 parent 1040098 commit 3b203a2a79c2f7b62857c56cbd28c57480f9e686 @weavejester committed Mar 15, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 test/compojure/test/core.clj
@@ -84,10 +84,14 @@
(request :get "/bar")))
(deftest context-test
- (testing "matching"
+ (testing "keyword matching"
(let [handler (context "/foo/:id" [id] identity)]
(is (map? (handler (request :get "/foo/10"))))
(is (nil? (handler (request :get "/bar/10"))))))
+ (testing "regex matching"
+ (let [handler (context ["/foo/:id" :id #"\d+"] [id] identity)]
+ (is (map? (handler (request :get "/foo/10"))))
+ (is (nil? (handler (request :get "/foo/ab"))))))
(testing "context key"
(let [handler (context "/foo/:id" [id] :context)]
(are [url ctx] (= (handler (request :get url)) ctx)

0 comments on commit 3b203a2

Please sign in to comment.