Permalink
Please sign in to comment.
Showing
with
113 additions
and 128 deletions.
- +1 −2 project.clj
- +4 −4 test/ring/handler/dump_test.clj
- +27 −27 test/ring/middleware/cookies_test.clj
- +18 −21 test/ring/middleware/file_info_test.clj
- +23 −23 test/ring/middleware/file_test.clj
- +14 −12 test/ring/middleware/lint_test.clj
- +12 −12 test/ring/middleware/params_test.clj
- +3 −3 test/ring/middleware/reload_test.clj
- +6 −6 test/ring/middleware/stacktrace_test.clj
- +5 −5 test/ring/middleware/static_test.clj
- +0 −13 test/run.clj
3
project.clj
8
test/ring/handler/dump_test.clj
54
test/ring/middleware/cookies_test.clj
| @@ -1,57 +1,57 @@ | ||
| (ns ring.middleware.cookies-test | ||
| - (:use clj-unit.core | ||
| + (:use clojure.test | ||
| ring.middleware.cookies)) | ||
| -(deftest "wrap-cookies: basic cookie" | ||
| +(deftest wrap-cookies-basic-cookie | ||
| (let [req {:headers {"cookie" "a=b"}} | ||
| resp ((wrap-cookies :cookies) req)] | ||
| - (assert= {"a" {:value "b"}} resp))) | ||
| + (is (= {"a" {:value "b"}} resp)))) | ||
| -(deftest "wrap-cookies: multiple cookies" | ||
| +(deftest wrap-cookies-multiple-cookies | ||
| (let [req {:headers {"cookie" "a=b; c=d,e=f"}} | ||
| resp ((wrap-cookies :cookies) req)] | ||
| - (assert= {"a" {:value "b"}, "c" {:value "d"}, "e" {:value "f"}} | ||
| - resp))) | ||
| + (is (= {"a" {:value "b"}, "c" {:value "d"}, "e" {:value "f"}} | ||
| + resp)))) | ||
| -(deftest "wrap-cookies: quoted cookies" | ||
| +(deftest wrap-cookies-quoted-cookies | ||
| (let [req {:headers {"cookie" "a=\"b=c;e=f\""}} | ||
| resp ((wrap-cookies :cookies) req)] | ||
| - (assert= {"a" {:value "b=c;e=f"}} | ||
| - resp))) | ||
| + (is (= {"a" {:value "b=c;e=f"}} | ||
| + resp)))) | ||
| -(deftest "wrap-cookies: escaped quotes" | ||
| +(deftest wrap-cookies-escaped-quotes | ||
| (let [req {:headers {"cookie" "a=\"\\\"b\\\"\""}} | ||
| resp ((wrap-cookies :cookies) req)] | ||
| - (assert= {"a" {:value "\"b\""}} | ||
| - resp))) | ||
| + (is (= {"a" {:value "\"b\""}} | ||
| + resp)))) | ||
| -(deftest "wrap-cookies: extra attrs" | ||
| +(deftest wrap-cookies-extra-attrs | ||
| (let [req {:headers {"cookie" "a=b;$Path=\"/\";$Domain=localhost"}} | ||
| resp ((wrap-cookies :cookies) req)] | ||
| - (assert= {"a" {:value "b", :path "/", :domain "localhost"}} | ||
| - resp))) | ||
| + (is (= {"a" {:value "b", :path "/", :domain "localhost"}} | ||
| + resp)))) | ||
| -(deftest "wrap-cookies: set basic cookie" | ||
| +(deftest wrap-cookies-set-basic-cookie | ||
| (let [handler (constantly {:cookies {"a" "b"}}) | ||
| resp ((wrap-cookies handler) {})] | ||
| - (assert= {"Set-Cookie" (list "a=\"b\"")} | ||
| - (:headers resp)))) | ||
| + (is (= {"Set-Cookie" (list "a=\"b\"")} | ||
| + (:headers resp))))) | ||
| -(deftest "wrap-cookies: set multiple cookies" | ||
| +(deftest wrap-cookies-set-multiple-cookies | ||
| (let [handler (constantly {:cookies {"a" "b", "c" "d"}}) | ||
| resp ((wrap-cookies handler) {})] | ||
| - (assert= {"Set-Cookie" (list "a=\"b\"" "c=\"d\"")} | ||
| - (:headers resp)))) | ||
| + (is (= {"Set-Cookie" (list "a=\"b\"" "c=\"d\"")} | ||
| + (:headers resp))))) | ||
| -(deftest "wrap-cookies: set keyword cookie" | ||
| +(deftest wrap-cookies-set-keyword-cookie | ||
| (let [handler (constantly {:cookies {:a "b"}}) | ||
| resp ((wrap-cookies handler) {})] | ||
| - (assert= {"Set-Cookie" (list "a=\"b\"")} | ||
| - (:headers resp)))) | ||
| + (is (= {"Set-Cookie" (list "a=\"b\"")} | ||
| + (:headers resp))))) | ||
| -(deftest "wrap-cookies: set extra attrs" | ||
| +(deftest wrap-cookies-set-extra-attrs | ||
| (let [cookies {"a" {:value "b", :path "/", :secure true}} | ||
| handler (constantly {:cookies cookies}) | ||
| resp ((wrap-cookies handler) {})] | ||
| - (assert= {"Set-Cookie" (list "a=\"b\";Path=\"/\";Secure")} | ||
| - (:headers resp)))) | ||
| + (is (= {"Set-Cookie" (list "a=\"b\";Path=\"/\";Secure")} | ||
| + (:headers resp))))) |
39
test/ring/middleware/file_info_test.clj
46
test/ring/middleware/file_test.clj
| @@ -1,43 +1,43 @@ | ||
| (ns ring.middleware.file-test | ||
| - (:use (clj-unit core) | ||
| + (:use (clojure test) | ||
| (ring.middleware file)) | ||
| (:import (java.io File))) | ||
| -(deftest "wrap-file: no directory" | ||
| - (assert-throws #"Directory does not exist" | ||
| - (wrap-file (constantly :response) (File. "not_here")))) | ||
| +(deftest wrap-file-no-directory | ||
| + (is (thrown-with-msg? Exception #".*Directory does not exist.*" | ||
| + (wrap-file (constantly :response) (File. "not_here"))))) | ||
| (def public-dir "test/ring/assets") | ||
| (def index-html (File. #^String public-dir "index.html")) | ||
| (def foo-html (File. #^String public-dir "foo.html")) | ||
| (def app (wrap-file (constantly :response) public-dir)) | ||
| -(deftest "wrap-file: unsafe method" | ||
| - (assert= :response (app {:request-method :post :uri "/foo"}))) | ||
| +(deftest wrap-file-unsafe-method | ||
| + (is (= :response (app {:request-method :post :uri "/foo"})))) | ||
| -(deftest "wrap-file: forbidden url" | ||
| +(deftest wrap-file-forbidden-url | ||
| (let [{:keys [status body]} (app {:request-method :get :uri "/../foo"})] | ||
| - (assert= 403 status) | ||
| - (assert-match #"Forbidden" body))) | ||
| + (is (= 403 status)) | ||
| + (is (re-find #"Forbidden" body)))) | ||
| -(deftest "wrap-file: directory" | ||
| +(deftest wrap-file-directory | ||
| (let [{:keys [status headers body]} (app {:request-method :get :uri "/"})] | ||
| - (assert= 200 status) | ||
| - (assert= {} headers) | ||
| - (assert= index-html body))) | ||
| + (is (= 200 status)) | ||
| + (is (= {} headers)) | ||
| + (is (= index-html body)))) | ||
| -(deftest "wrap-file: file without extension" | ||
| +(deftest wrap-file-sans-extension | ||
| (let [{:keys [status headers body]} (app {:request-method :get :uri "/foo"})] | ||
| - (assert= 200 status) | ||
| - (assert= {} headers) | ||
| - (assert= foo-html body))) | ||
| + (is (= 200 status)) | ||
| + (is (= {} headers)) | ||
| + (is (= foo-html body)))) | ||
| -(deftest "wrap-file: file with extension" | ||
| +(deftest wrap-file-with-extension | ||
| (let [{:keys [status headers body]} (app {:request-method :get :uri "/foo.html"})] | ||
| - (assert= 200 status) | ||
| - (assert= {} headers) | ||
| - (assert= foo-html body))) | ||
| + (is (= 200 status)) | ||
| + (is (= {} headers)) | ||
| + (is (= foo-html body)))) | ||
| -(deftest "wrap-file: no file" | ||
| - (assert= :response (app {:request-method :get :uri "/dynamic"}))) | ||
| +(deftest wrap-file-no-file | ||
| + (is (= :response (app {:request-method :get :uri "/dynamic"})))) |
26
test/ring/middleware/lint_test.clj
24
test/ring/middleware/params_test.clj
6
test/ring/middleware/reload_test.clj
| @@ -1,9 +1,9 @@ | ||
| (ns ring.middleware.reload-test | ||
| - (:use (clj-unit core) | ||
| + (:use (clojure test) | ||
| (ring.middleware reload))) | ||
| (def app | ||
| (wrap-reload (constantly :response) '(ring.middleware.reload))) | ||
| -(deftest "wrap-reload" | ||
| - (assert= :response (app :request))) | ||
| +(deftest wrap-reload-smoke | ||
| + (is (= :response (app :request)))) |
12
test/ring/middleware/stacktrace_test.clj
| @@ -1,16 +1,16 @@ | ||
| (ns ring.middleware.stacktrace-test | ||
| - (:use (clj-unit core) | ||
| + (:use (clojure test) | ||
| (ring.middleware stacktrace))) | ||
| (def app (wrap-stacktrace #(throw (Exception. "fail")))) | ||
| (def html-req {}) | ||
| (def js-req {:headers {"accept" "text/javascript"}}) | ||
| -(deftest "wrap-stacktrace" | ||
| +(deftest wrap-stacktrace-smoke | ||
| (let [{:keys [status headers] :as response} (app html-req)] | ||
| - (assert= 500 status) | ||
| - (assert= {"Content-Type" "text/html"} headers)) | ||
| + (is (= 500 status)) | ||
| + (is (= {"Content-Type" "text/html"} headers))) | ||
| (let [{:keys [status headers]} (app js-req)] | ||
| - (assert= 500 status) | ||
| - (assert= {"Content-Type" "text/javascript"} headers))) | ||
| + (is (= 500 status)) | ||
| + (is (= {"Content-Type" "text/javascript"} headers)))) |
10
test/ring/middleware/static_test.clj
13
test/run.clj
| @@ -1,13 +0,0 @@ | ||
| -(set! *warn-on-reflection* true) | ||
| - | ||
| -(use 'clj-unit.core) | ||
| -(require-and-run-tests | ||
| - 'ring.handler.dump-test | ||
| - 'ring.middleware.lint-test | ||
| - 'ring.middleware.file-test | ||
| - 'ring.middleware.file-info-test | ||
| - 'ring.middleware.static-test | ||
| - 'ring.middleware.reload-test | ||
| - 'ring.middleware.stacktrace-test | ||
| - 'ring.middleware.params-test | ||
| - 'ring.middleware.cookies-test) |
0 comments on commit
4eedbc9