store/[org.clojure/clojure "1.8.0"] clj::clojure.core/with-redefs-fn

Official Documentation

Add notes
Arities
==================================================
   [binding-map func]

Docstring
==================================================
  Temporarily redefines Vars during a call to func.  Each val of
  binding-map will replace the root value of its key which must be
  a Var.  After func is called with no args, the root values of all
  the Vars will be set back to their old values.  These temporary
  changes will be visible in all threads.  Useful for mocking out
  functions during testing.

Source

(defn with-redefs-fn
  "Temporarily redefines Vars during a call to func.  Each val of
  binding-map will replace the root value of its key which must be
  a Var.  After func is called with no args, the root values of all
  the Vars will be set back to their old values.  These temporary
  changes will be visible in all threads.  Useful for mocking out
  functions during testing."
  {:added "1.3"}
  [binding-map func]
  (let [root-bind (fn [m]
                    (doseq [[a-var a-val] m]
                      (.bindRoot ^clojure.lang.Var a-var a-val)))
        old-vals (zipmap (keys binding-map)
                         (map #(.getRawRoot ^clojure.lang.Var %) (keys binding-map)))]
    (try
      (root-bind binding-map)
      (func)
      (finally
        (root-bind old-vals)))))

Example 1

Edit
(ns http)

(defn post [url]
  {:body "Hello world"})

(ns app
  (:require [clojure.test :refer [run-tests]]))

(deftest is-a-fn
  (with-redefs-fn {#'http/post (fn [url] {:body "Hello world again"})}
    #(is (= {:body "Hello world again"} (http/post "http://service.com/greet")))))

(run-tests) ;; test is passing

Example 2

Edit
=> (defn f [] false)

=> (println (f))
;; false

=> (with-redefs-fn {#'f (fn [] true)} 
     #(println (f)))
;; true

Uses on crossclj