Skip to content
This repository has been archived by the owner on Jan 23, 2018. It is now read-only.

technomancy/rodney-leonard-stubbs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

The simplest stubs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published