Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pass args to function we use as the stub #1

Closed
AlexBaranosky opened this Issue · 0 comments

1 participant

@AlexBaranosky
Collaborator

Code change:

(defn stub-fn [function-name return-value]
  (swap! call-times assoc function-name [])
  (fn [& args]
    (swap! call-times update-in [function-name] conj args)
    (if (fn? return-value)
      (apply return-value args) ;; pass the args in
      return-value)))

This way you can say:

(binding [logger (fn [msg] (println "we're logging your message: " msg))]
  (is (= :foo (bar-maker))))
@AlexBaranosky AlexBaranosky referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.