"He was the Thomas Edison of handing a dude his ass."
Rodney Leonard Stubbs may very well be the simplest stubbing system ever.
Add rodney.leonard.stubbs to your :hooks list in project.clj. Add :mock metadata to functions to have them replaced at test-time with their mocks.
(defn ^{:mock (constantly [:jeep1])} release-jeeps
(network-intensive-operation))
Now when tests are run (via clojure.test/run-tests in either the lein test task or manually in a repl/swank session), the release-jeeps function will be replaced with a function that returns [:jeep1] no matter what args it's called with.
Note that this replacement happens using alter-var-root, not binding, so it will affect all threads, and it will not be reverted at the end of the test run. This may be useful to help with repl exploration.
Also note that the var's original value will be kept on the :stubbs/original key in the metadata of the replacement in case it's needed.
Copyright (C) 2010 Phil Hagelberg
Distributed under the Eclipse Public License, the same as Clojure.