Skip to content

Instantly share code, notes, and snippets.

@kurtharriger
Created April 15, 2012 17:36
Show Gist options
  • Select an option

  • Save kurtharriger/2394051 to your computer and use it in GitHub Desktop.

Select an option

Save kurtharriger/2394051 to your computer and use it in GitHub Desktop.
Midje provided issue
(defn mocked [x] (Exception. "should not be called"))
(defn withmocked [x] (mocked (inc x)))
;.;. FAIL at (NO_SOURCE_FILE:1)
;.;. Expected: 3
;.;. Actual: #<Exception java.lang.Exception: should not be called>
(facts "Fails if mocked is called twice"
(let [x 2]
(mocked 3) => 3
(withmocked x) => 3
)
(provided
(mocked 3) => 3
))
(facts "But works if I comment out the first fact"
(let [x 2]
(mocked 3) => 3
;; (withmocked x) => 3
)
(provided
(mocked 3) => 3
))
(facts "Or if I comment out the second fact"
(let [x 2]
;; (mocked 3) => 3
(withmocked x) => 3
)
(provided
(mocked 3) => 3
))
(facts "Or use with-redefs"
(with-redefs [mocked (fn [x] 3)]
(let [x 2]
(mocked 3) => 3
(withmocked x) => 3
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment