Skip to content

Instantly share code, notes, and snippets.

@tcrayford
Last active December 14, 2015 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcrayford/5125398 to your computer and use it in GitHub Desktop.
Save tcrayford/5125398 to your computer and use it in GitHub Desktop.
; fails
(defn calls-callback [callback]
(fn [thing] (callback thing)))
(defn callback [a] (print a))
(fact "calls-callback can be mocked to check the callback is called"
(let [closed (calls-callback callback)]
(closed 1) => anything
(provided (callback 1) => ...ignored... :times 1)))
; fails
(defn calls-callback [callback]
(fn [thing] (callback thing)))
(fact "calls-callback can be mocked to check the callback is called"
(let [closed (calls-callback ...callback...)]
(closed 1) => anything
(provided (...callback... 1) => ...ignored... :times 1)))
; passes
(fact "calls-callback can be mocked to check the callback is called"
((calls-callback ...callback...) 1) => anything
(provided (...callback... 1) => ...ignored... :times 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment