Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

The simplest stubs

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 project.clj
README.md

Rodney Leonard Stubbs

"He was the Thomas Edison of handing a dude his ass."

Rodney Leonard Stubbs may very well be the simplest stubbing system ever.

Usage

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.

License

Copyright (C) 2010 Phil Hagelberg

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.