Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
spying for tests
Clojure
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/bond
test/bond/test
.gitignore
README.md
project.clj

README.md

Bond CircleCI Status

Bond is a spying and stubbing library, primarily intended for tests.

[bond "0.2.5"]
(ns test.foo
  (:require [bond.james :as bond :refer [with-spy]))

(defn foo [x] ...)

(defn bar [y]
   (foo y))

(deftest foo-is-called
  (with-spy [foo]
    (bar 2)
    (is (= 1 (-> foo bond/calls count)))))

Bond provides one main macro, with-spy. It takes a vector of defn vars (vars that resolve to fns). Each var will be redef'd, wrapping the fn to track arguments and call counts. At any point during the scope, you can call (bond/calls f), where f is a spied fn. calls returns a seq of maps, one for each call to f. Each map contains the keys :args, a seq of args the fn was called with, and one of :return or :throw.

Bond also provides with-stub. It works the same as with-spy, but redefines the fn to return (constantly nil), while also spying on it.

License

Distributed under the Eclipse Public License.

Something went wrong with that request. Please try again.