Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added route/resources function and unit tests
- Loading branch information
1 parent
583236e
commit 5e3543f
Showing
3 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
(ns compojure.test.route | |||
(:use clojure.test | |||
[clojure.contrib.duck-streams :only (slurp*)]) | |||
(:require [compojure.route :as route])) | |||
|
|||
(deftest not-found-route | |||
(let [response ((route/not-found "foo") {})] | |||
(is (= (:status response) 404)) | |||
(is (= (:body response) "foo")))) | |||
|
|||
(deftest resources-route | |||
(let [route (route/resources "/foo" {:root "resources"}) | |||
response (route {:request-method :get, :uri "/foo/test.txt"})] | |||
(is (= (:status response) 200)) | |||
(is (= (slurp* (:body response)) "foobar\n")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
foobar |