私はCompojureアプリケーションを作成していて、clj-webdriver
それをグラフィカルにテストするために使用しています。with-redefs
永続性からデータを引き出して固定値を返す関数をモックアウトしようとしていますが、関数の上書きを無視しています。varsの観点からは機能することはわかってwith-redefs
いますが、まだ機能していません。
project.clj関連の部分:
(defproject run-hub "0.1.0-SNAPSHOT"
:main run-hub.handler/start-server)
handler.clj:
(ns run-hub.handler
(:require [compojure.core :refer :all]
[compojure.handler :as handler]
[compojure.route :as route]
[ring.adapter.jetty :refer :all]
[run-hub.controllers.log-controller :as log-controller]))
(defroutes app-routes
(GET "/MikeDrogalis/log" [] (log-controller/mikes-log))
(route/resources "/")
(route/not-found "Not Found"))
(def app (handler/site #'app-routes))
log-controller.clj:
(ns run-hub.controllers.log-controller
(:require [run-hub.views.log :as views]
[run-hub.persistence :as persistence]))
(defn mikes-log []
(views/mikes-log (persistence/mikes-log)))
永続性.clj
(ns run-hub.persistence
(require [clj-time.core :as time]
[run-hub.models.log :as log]))
(defn mikes-log [] [])
そして最後に、私のグラフィカルテスト-オーバーライドしようとしてmikes-log
失敗します:
(fact
"It has the first date of training as August 19, 2012"
(with-redefs [persistence/mikes-log (fn [] (one-week-snippet))]
(to (local "/MikeDrogalis/log"))
(.contains (text "#training-log") "August 19, 2012"))
=> true)
one-week-snippet
いくつかのサンプルデータを返す関数はどこにありますか。(defn start-server [](run-jetty(var app){:port 3000:join?false}))