From b17ce9fbb29483eb8f6e591a1ff282db453a4713 Mon Sep 17 00:00:00 2001 From: Tom Faulhaber Date: Wed, 2 Jun 2010 10:47:29 -0700 Subject: Autodoc commit for master/4fe738db, 1.1.x/d132c5f1 --- branch-1.1.x/mock-api.html | 360 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 358 insertions(+), 2 deletions(-) (limited to 'branch-1.1.x/mock-api.html') diff --git a/branch-1.1.x/mock-api.html b/branch-1.1.x/mock-api.html index 02f7ddec..56efea5d 100644 --- a/branch-1.1.x/mock-api.html +++ b/branch-1.1.x/mock-api.html @@ -40,7 +40,7 @@ namespace. API Index
Namespaces: @@ -53,7 +53,51 @@ namespace.

Table of Contents

Overview - +
+ calls +
+ expect +
+ has-args +
+ has-matching-signature? +
+ make-arg-checker +
+ make-count-checker +
+ make-mock +
+ returns +
+ times +
+ validate-counts +
+
+
+ mock.test-adapter +
+ calls +
+ has-args +
+ has-matching-signature? +
+ make-arg-checker +
+ make-count-checker +
+ make-mock +
+ report-problem +
+ returns +
+ times +
+ validate-counts +

@@ -72,7 +116,319 @@ by Unknown

Public Variables and Functions

+
+
+
+

calls

+ function
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
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
+
Usage: (validate-counts mock-data)
+
+
given the sequence of all mock data for the expectation, simply calls the
+count checker for each dependency.
+ + + Source +
-- cgit v1.2.3-18-g5258