Created
April 15, 2012 17:36
-
-
Save kurtharriger/2394051 to your computer and use it in GitHub Desktop.
Midje provided issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn mocked [x] (Exception. "should not be called")) | |
| (defn withmocked [x] (mocked (inc x))) | |
| ;.;. [31mFAIL[0m 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