midje

Using midje provided in a let clause doesn't stub methods

拈花ヽ惹草 提交于 2020-01-15 05:27:44
问题 When I make a test using an outer let clause to structure some definitions and calls, the stubs don't work the way I'd expect. For example: This test fails (fact "blah" (let [x (meth1 123)] x => 246 (provided (meth2 123) => 246))) With this code (defn meth2 [x] (prn "meth2" x) (* 3 x)) (defn meth1 [x] (let [y (meth2 x)] y)) Am I not supposed to use let statements with midje? I can't understand how to get these to pass without removing the let . 回答1: First of all, your test would even fail if

Midje provided not stubbing function in Compojure / Ring handler

自作多情 提交于 2019-12-11 11:04:09
问题 I'm attempting to use Midje to stub the view in a handler unit test, but my use of Midje's (provided) obviously isn't correct. I've simplified and inlined the view to a (content) function in the handler: (ns whattodo.handler (:use compojure.core) (:require [whattodo.views :as views])) (defn content [] (views/index)) (defn index [] (content)) (defroutes app (GET "/" [] (index))) and am trying to test it using (ns whattodo.t-handler (:use midje.sweet) (:use ring.mock.request) (:use whattodo