 ;;;; ___________________________________________________________________________
 ;;;; ---- rmp/wrap-params ----
 
-(fact ((-> identity-handler
-           rmp/wrap-params)
-       my-request)
-  => (just (merge my-request
-                  {:body         anything
-                   :form-params  {}
-                   :params       {"q1" "a"
-                                  "q2" "b"}
-                   :query-params {"q1" "a"
-                                  "q2" "b"}})))
+(let [req (make-my-request)]
+  (fact ((-> identity-handler
+             rmp/wrap-params)
+         req)
+    => (just (merge req
+                    {:body         anything
+                     :form-params  {}
+                     :params       {"q1" "a"
+                                    "q2" "b"}
+                     :query-params {"q1" "a"
+                                    "q2" "b"}}))))
 
 ;;;; ___________________________________________________________________________
 ;;;; ---- rmj/wrap-json-params ----
 
-(fact ((-> identity-handler
-           rmj/wrap-json-params)
-       my-request)
-  => (just (merge my-request
-                  {:body        anything
-                   :json-params {"user" "Fred"}
-                   :params      {"user" "Fred"}})))
+(let [req (make-my-request)]
+  (fact ((-> identity-handler
+             rmj/wrap-json-params)
+         req)
+    => (just (merge req
+                    {:body        anything
+                     :json-params {"user" "Fred"}
+                     :params      {"user" "Fred"}}))))
 
 ;;;; ___________________________________________________________________________
 


(fact "Wrapped handler with request whose body is JSON"
  (wrapped-handler-of-interesting-request
   {:headers {"content-type" "application/json; charset=utf-8"}
    :body (string->stream "{\"user\":\"Fred\"}")})
  => {:status 200
      :headers {}
      :body "Uploaded 'Fred'."})

(defn identity-handler [request]
  request)

(defn make-my-request []
  ;; This is a function rather than a var, so for each call the return value's
  ;; `:body` stream can be consumed separately.
  {:headers {"content-type" "application/json; charset=utf-8"}
   :query-string "q1=a&q2=b"
   :body (string->stream "{\"user\":\"Fred\"}")})
