     io.aviso.rook
     io.aviso.rook.schema-validation)
   (:require
+    [clojure.core.async :refer [<!!]]
     [schema.core :as s]
     [clojure.tools.logging :as l]
     [io.aviso.rook.async :as async]))

          (should= HttpServletResponse/SC_BAD_REQUEST (:status response))
          (should= "validation-error" (-> response :body :error))))

    (it "ignores extra keys"
        (should-be-nil
          (validate-against-schema {:params {:name "Rook" :ssn "999-99-9999"}} example-schema))))

          (should= HttpServletResponse/SC_BAD_REQUEST
                   (->
                     (request :post "/")
                     (assoc :params {:first-name "Wrong Key"})
                     handler
                     :status)))))

  (describe "async middleware"

    (let [handler (async/namespace-handler 'validating)]
      (it "is present in the default async pipeline"
          (should= HttpServletResponse/SC_BAD_REQUEST
                   (->
                     (request :post "/")
                     (assoc :params {:first-name "Wrong Key"})
                     handler
                     <!!
                     :status)))

      (it "does not interfere with valid request"

          (should= HttpServletResponse/SC_OK
                   (->
                     (request :post "/")
                     (assoc :params {:name "Provided"})
                     handler
                     <!!
                     :status))))))



(run-specs)
