Is it possible to return different responses whenever you are invoking the same provided multiple times?
(defn f2 [x] (* x x))
(defn f1 [x] (+ (f2 x) (f2 x)))
(fact "testing multiple provided"
(f1 2) => 12
(provided (f2 2) => 5)
(provided (f2 2) => 7))
Right now I solve it like this:
(defn f2 [x] (* x x))
(defn f1 [x] (+ (f2 x) (f2 x)))
(def ^:private mutable-value (atom 5))
(fact "testing multiple provided"
(let [value (fn []
(do
(swap! mutable-value inc)
@mutable-value))]
(f1 2) => 12
(provided (f2 2) => (value))))
Is there any other way of doing it? Am I missing something really obvious?