Skip to content

clojure.core/with-redefs

View this page on ClojureDocs

Type: macro Added: Clojure 1.3 Examples: 7 Runnable: 1
([bindings & body])

binding => var-symbol temp-value-expr

Temporarily redefines Vars while executing the body. The temp-value-exprs will be evaluated and each resulting value will replace in parallel the root value of its Var. After the body is executed, 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.

Examples

by devn on . May have evaluation errors.
by johnnyluu on
by w01fe on . May have evaluation errors.
by nickzam on . May have evaluation errors.
by deadghost on . May have evaluation errors.
by owenRiddy on . May have evaluation errors.
by tomdl89 on . May have evaluation errors.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.