         (is (= (get-in response [:headers "Content-Type"]) "application/json"))))))
 
 (deftest getting-a-card
-  (with-redefs [cards/find-by-id (fn [id] a-card)]
+  (with-redefs [cards/find-by-id (constantly a-card)]
     (let [response (cards-handler/cards-routes (mock/request :get (str "/cards/" (:id a-card))))]
       (testing "Responds with 200"
         (is (= (:status response) 200)))

        (is (= (get-in response [:body :message]) "Could not find a card with id 123"))))))

(deftest inserting-a-card
  (with-redefs [cards/insert (fn [attrs] a-card)]
    (let [attrs (select-keys a-card [:title :contents])
          response (cards-handler/cards-routes (mock/request :post "/cards" attrs))]
      (testing "Responds with 200"

        (is (= (get-in response [:headers "Content-Type"]) "application/json"))))))

(deftest getting-a-not-found-card
  (with-redefs [cards/find-by-id (constantly nil)]
    (let [response (cards-handler/cards-routes (mock/request :get "/cards/123"))]
      (testing "Responds with 404"
        (is (= (:status response) 404)))
