Liking cljdoc? Tell your friends :D

spy.core

A testing framework for stubs, spies and mocks. Enables verification of interactions with a function.

A testing framework for stubs, spies and mocks.
Enables verification of interactions with a function.
raw docstring

call-countclj/s

(call-count f)

Returns the count of the number of calls to the spy f.

Returns the count of the number of calls to the spy f.
sourceraw docstring

call-matching?clj/s

(call-matching? f pred)

Returns true if any of the calls to the spy f match the predicate

Returns true if any of the calls to the spy f match the predicate
sourceraw docstring

called-at-least-n-times?clj/s

(called-at-least-n-times? f n)

Returns true if the spy f was called at least n times, false if not.

Returns true if the spy f was called at least n times, false if not.
sourceraw docstring

called-at-least-once?clj/s

(called-at-least-once? f)

Returns true if the spy f was called at least once, false if not.

Returns true if the spy f was called at least once, false if not.
sourceraw docstring

called-n-times-with?clj/s

(called-n-times-with? f n pred)

Returns true if the spy f has n calls matching the predicate, false if not.

Returns true if the spy f has n calls matching the predicate, false if not.
sourceraw docstring

called-n-times?clj/s

(called-n-times? f n)

Returns true if the spy f was called n times, false if not.

Returns true if the spy f was called n times, false if not.
sourceraw docstring

called-no-more-than-n-times?clj/s

(called-no-more-than-n-times? f n)

Returns true if the spy f was called no more than n times, false if not.

Returns true if the spy f was called no more than n times, false if not.
sourceraw docstring

called-no-more-than-once?clj/s

(called-no-more-than-once? f)

Returns true if the spy f was called once or not at all, false if not.

Returns true if the spy f was called once or not at all, false if not.
sourceraw docstring

called-once-with?clj/s

(called-once-with? f & args)

Returns true if there was only one call to the spy f and the args match, false if not.

Returns true if there was only one call to the spy f and the args match, false if not.
sourceraw docstring

called-once?clj/s

(called-once? f)

Returns true if the spy f was called once, false if not.

Returns true if the spy f was called once, false if not.
sourceraw docstring

called-with?clj/s

(called-with? f & args)

Returns true if any of the calls to the spy f match the args, false if no calls match.

Returns true if any of the calls to the spy f match the args, false if no calls match.
sourceraw docstring

called?clj/s

(called? f)

Returns true is the spy f was called, false if not.

Returns true is the spy f was called, false if not.
sourceraw docstring

callsclj/s

(calls f)

Returns a list of all calls to the spy f.

Returns a list of all calls to the spy f.
sourceraw docstring

first-callclj/s

(first-call f)

Returns the first call to the spy f

Returns the first call to the spy f
sourceraw docstring

first-responseclj/s

(first-response f)

Returns the first response returned by the spy f.

Returns the first response returned by the spy f.
sourceraw docstring

last-callclj/s

(last-call f)

Returns the last call to the spy f

Returns the last call to the spy f
sourceraw docstring

last-responseclj/s

(last-response f)

Returns the last response returned by the spy f.

Returns the last response returned by the spy f.
sourceraw docstring

mockclj/s

(mock f)

An alias for spy, behaviour for the function is provided by the user.

An alias for spy, behaviour for the function is provided by the user.
sourceraw docstring

not-called-with?clj/s

(not-called-with? f & args)

Returns true if the no calls to the spy f match the args, false if a call matches.

Returns true if the no calls to the spy f match the args, false if a call matches.
sourceraw docstring

not-called?clj/s

(not-called? f)

Returns true if the spy f was never called, false if not.

Returns true if the spy f was never called, false if not.
sourceraw docstring

nth-callclj/s

(nth-call f n)

Returns the nth call to the spy f for the index n.

Returns the nth call to the spy f for the index n.
sourceraw docstring

nth-responseclj/s

(nth-response f n)

Returns the response of the spy f at the index n.

Returns the response of the spy f at the index n.
sourceraw docstring

reset-spy!clj/s

(reset-spy! f)

Resets the calls and responses on the spy f.

Resets the calls and responses on the spy f.
sourceraw docstring

responsesclj/s

(responses f)

Returns a list of all responses returned by the spy f.

Returns a list of all responses returned by the spy f.
sourceraw docstring

spyclj/s

(spy)
(spy f)

If no function is supplied, returns a function that takes any number of args and returns nil.

If a function is supplied, returns a function that wraps the function.

Adds metadata {:calls (atom []) :responses (atom [])} to the function, calls and responses are recorded and stored inside the atoms.

If an exception is thrown by the function this is caught, recorded as a response nested in a map under the key :thrown, and rethrown.

If no function is supplied, returns a function that takes any number of args
and returns nil.

If a function is supplied, returns a function that wraps the function.

Adds metadata {:calls (atom []) :responses (atom [])} to the function, calls
and responses are recorded and stored inside the atoms.

If an exception is thrown by the function this is caught, recorded as a response
nested in a map under the key :thrown, and rethrown.
sourceraw docstring

stubclj/s

(stub)
(stub value)

Returns a spy function that returns the value supplied, or nil if no value is supplied.

Returns a spy function that returns the value supplied, or nil
if no value is supplied.
sourceraw docstring

stub-throwsclj/s

(stub-throws exception)

Returns a spy function that throws the exception provided.

Returns a spy function that throws the exception provided.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close