Skip to content

Instantly share code, notes, and snippets.

@astahlman
Created May 7, 2015 01:45
Show Gist options
  • Save astahlman/b62b95ab62e48e338246 to your computer and use it in GitHub Desktop.
Save astahlman/b62b95ab62e48e338246 to your computer and use it in GitHub Desktop.
Example of how def'ing doesn't play nice with Midje prerequisites.
(ns midje-example.mock
(:use midje.sweet))
(defn compute [comp-fn]
(comp-fn 2 3))
(unfinished mult)
;; At compile time...
;; #`midje-example.mock/bound-to-mult => #'midje-example.mock/mult
(def bound-to-mult mult)
(fact "The mock is not invoked when we inject a Var bound to the mocked function"
(compute bound-to-mult) => 6 ;; #'midje-example.mock/bound-to-mult => ;; (unfinished mult)
(provided
(mult 2 3) => 6)) ;; #'midje-example.mock/mult => <mock implementation>
(fact "But it is called if we mock the injected Var directly"
(compute bound-to-mult) => 6 ;; #'midje-example.mock/bound-to-mult => <mock implementation>
(provided
(bound-to-mult 2 3) => 6)) ;; #'midje-example.mock/bound-to-mult => <mock implementation>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment