API for mock - clojure-contrib v1.2 (stable)

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at http://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.mock

Overview





Public Variables and Functions



calls

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (calls val)
       (calls val expectation-hash)
Creates or associates to an existing expectation hash the :calls key with a
function that will be called with the given arguments. The return value from
this function will be returned returned by the expected function. If both this
and returns are specified, the return value of "calls" will have precedence.
Usage:
(calls some-fn expectation-hash?)
Source


expect

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (expect expect-bindings & body)
Use expect to redirect calls to dependent functions that are made within the
code under test. Instead of calling the functions that would normally be used,
temporary stubs are used, which can verify function parameters and call counts.
Return values can also be specified as needed.
Usage:
(expect [dep-fn (has-args [arg-pred1] (times n (returns x)))]
  (function-under-test a b c))
Source


has-args

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (has-args arg-pred-forms)
       (has-args arg-pred-forms expect-hash-form)
Creates or associates to an existing expectation hash the :has-args key with
a value corresponding to a function that will either return true if its
argument expectations are met or throw an exception with the details of the
first failed argument it encounters.
Only specify as many predicates as you are interested in verifying. The rest
of the values are safely ignored.
Usage:
(has-args [arg-pred-1 arg-pred-2 ... arg-pred-n] expectation-hash?)
Source


has-matching-signature?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (has-matching-signature? fn-name args)
Calls no-matching-function-signature if no match is found for the given
function. If no argslist meta data is available for the function, it is
not called.
Source


make-arg-checker

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-arg-checker arg-preds arg-pred-forms)
Creates the argument verifying function for a replaced dependency within
the expectation bound scope. These functions take the additional argument
of the name of the replaced function, then the rest of their args. It is
designed to be called from the mock function generated in the first argument
of the mock info object created by make-mock.
Source


make-count-checker

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-count-checker pred pred-form)
creates the count checker that is invoked at the end of an expectation, after
the code under test has all been executed. The function returned takes the
name of the associated dependency and the invocation count as arguments.
Source


make-mock

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-mock fn-name expectation-hash)
creates a vector containing the following information for the named function:
1. dependent function replacement - verifies signature, calls arg checker,
increases count, returns return value.
2. an atom containing the invocation count
3. the invocation count checker function
4. a symbol of the name of the function being replaced.
Source


returns

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (returns val)
       (returns val expectation-hash)
Creates or associates to an existing expectation hash the :returns key with
a value to be returned by the expectation after a successful invocation
matching its expected arguments (if applicable).
Usage:
(returns ret-value expectation-hash?)
Source


times

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (times times-fn)
       (times times-fn expectation-hash)
Creates or associates to an existing expectation hash the :times key with a
value corresponding to a predicate function which expects an integer value.
This function can either be specified as the first argument to times or can be
the result of calling times with an integer argument, in which case the
predicate will default to being an exact match.  This predicate is called at
the end of an expect expression to validate that an expected dependency
function was called the expected number of times.
Usage:
(times n)
(times #(> n %))
(times n expectation-hash)
Source


validate-counts

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (validate-counts mock-data)
given the sequence of all mock data for the expectation, simply calls the
count checker for each dependency.
Source

mock.test-adapter






calls

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (calls val)
       (calls val expectation-hash)
Creates or associates to an existing expectation hash the :calls key with a
function that will be called with the given arguments. The return value from
this function will be returned returned by the expected function. If both this
and returns are specified, the return value of "calls" will have precedence.
Usage:
(calls some-fn expectation-hash?)
Source

has-args

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (has-args arg-pred-forms)
       (has-args arg-pred-forms expect-hash-form)
Creates or associates to an existing expectation hash the :has-args key with
a value corresponding to a function that will either return true if its
argument expectations are met or throw an exception with the details of the
first failed argument it encounters.
Only specify as many predicates as you are interested in verifying. The rest
of the values are safely ignored.
Usage:
(has-args [arg-pred-1 arg-pred-2 ... arg-pred-n] expectation-hash?)
Source

has-matching-signature?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (has-matching-signature? fn-name args)
Calls no-matching-function-signature if no match is found for the given
function. If no argslist meta data is available for the function, it is
not called.
Source

make-arg-checker

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-arg-checker arg-preds arg-pred-forms)
Creates the argument verifying function for a replaced dependency within
the expectation bound scope. These functions take the additional argument
of the name of the replaced function, then the rest of their args. It is
designed to be called from the mock function generated in the first argument
of the mock info object created by make-mock.
Source

make-count-checker

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-count-checker pred pred-form)
creates the count checker that is invoked at the end of an expectation, after
the code under test has all been executed. The function returned takes the
name of the associated dependency and the invocation count as arguments.
Source

make-mock

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-mock fn-name expectation-hash)
creates a vector containing the following information for the named function:
1. dependent function replacement - verifies signature, calls arg checker,
increases count, returns return value.
2. an atom containing the invocation count
3. the invocation count checker function
4. a symbol of the name of the function being replaced.
Source

report-problem

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (report-problem fn-name expected actual msg)
This function is designed to be used in a binding macro to override
the report-problem function in clojure.contrib.mock. Instead of printing
the error to the console, the error is logged via clojure.test.
Source

returns

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (returns val)
       (returns val expectation-hash)
Creates or associates to an existing expectation hash the :returns key with
a value to be returned by the expectation after a successful invocation
matching its expected arguments (if applicable).
Usage:
(returns ret-value expectation-hash?)
Source

times

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (times times-fn)
       (times times-fn expectation-hash)
Creates or associates to an existing expectation hash the :times key with a
value corresponding to a predicate function which expects an integer value.
This function can either be specified as the first argument to times or can be
the result of calling times with an integer argument, in which case the
predicate will default to being an exact match.  This predicate is called at
the end of an expect expression to validate that an expected dependency
function was called the expected number of times.
Usage:
(times n)
(times #(> n %))
(times n expectation-hash)
Source

validate-counts

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (validate-counts mock-data)
given the sequence of all mock data for the expectation, simply calls the
count checker for each dependency.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.