Liking cljdoc? Tell your friends :D

shrubbery.core

A collection of functions for creating and querying stubs, spies, and mocks.

A collection of functions for creating and querying stubs, spies, and mocks.
raw docstring

anythingclj

A Matcher that always returns true.

A [[Matcher]] that always returns true.
sourceraw docstring

call-countclj

(call-count aspy avar)
(call-count aspy avar args)

Given a spy, a var, and an optional vector of args, return the number of times the spy received the method. If given args, filters the list of calls by matching the given args. Matched args may implement the Matcher protocol; the default implementation for Object is =.

Given a [[spy]], a var, and an optional vector of args, return the number of times the spy received
the method. If given args, filters the list of calls by matching the given args. Matched args may implement the
[[Matcher]] protocol; the default implementation for `Object` is `=`.
sourceraw docstring

Matchercljprotocol

A protocol for defining argument equality matching. Default implementations are provided for Object (equality), Pattern (regexp matching), and IFn (execution). There is also a wildcard matcher, anything.

A protocol for defining argument equality matching. Default implementations are provided for `Object` (equality),
`Pattern` (regexp matching), and `IFn` (execution). There is also a wildcard matcher, [[anything]].

matches?clj

(matches? matcher value)
sourceraw docstring

mockclj

(mock & protos-and-impls)

Given a protocol and a hashmap of function implementations, returns a new implementation of that protocol with those implementations. The returned implementation is also a spy, allowing you to inspect and assert against its calls. See spy and stub.

Given a protocol and a hashmap of function implementations, returns a new implementation of that protocol with those
implementations. The returned implementation is also a spy, allowing you to inspect and assert against its calls.
See [[spy]] and [[stub]].
sourceraw docstring

protocol?clj

(protocol? p)

True if p is a protocol.

True if p is a protocol.
sourceraw docstring

protocolsclj

(protocols o)

Given an object, attempt to return the set of all protocols it reifies. Warning: this may choke on nonstandard package and namespace choices. Pull requests and bug reports welcome.

Given an object, attempt to return the set of all protocols it reifies. Warning: this may choke
on nonstandard package and namespace choices. Pull requests and bug reports welcome.
sourceraw docstring

received?clj

(received? aspy avar)
(received? aspy avar args)

Given a spy and a method reference, return true if the method has been called on the spy at least once. If given args, filters the list of calls by matching the given args. Matched args may implement the Matcher protocol; the default implementation for Object is =.

Given a [[spy]] and a method reference, return true if the method has been called on the spy at least once. If given
args, filters the list of calls by matching the given args. Matched args may implement the [[Matcher]] protocol;
the default implementation for `Object` is `=`.
sourceraw docstring

returningclj

(returning s proto new-stubs)

Given a stub or mock, a protocol, and a hashmap of implementations, return a new stub that replaces the stubs for the named function with the given stubs.

Given a [[stub]] or [[mock]], a protocol, and a hashmap of implementations, return a new stub that replaces the stubs
for the named function with the given stubs.
sourceraw docstring

Spycljprotocol

A protocol shared by spies.

A protocol shared by spies.

callsclj

(calls t)

Returns a map of function names to lists of received args, one for each time the function is called.

Returns a map of function names to lists of received
args, one for each time the function is called.

proxiedclj

(proxied t)

Returns the underlying object this spy proxies its calls to.

Returns the underlying object this spy proxies its calls to.
sourceraw docstring

spyclj

(spy o)
(spy o protos)

Given an object implementing one or more protocols, returns a new object that records each call to underlying protocol functions, then proxies to the original implementation. The returned object also implements Spy, which exposes those calls. If an explicit list of protocols is not given, the list will be inferred from the given object. For spies with added implementation, see mock. For queryies against spies, see call-count and received?.

Given an object implementing one or more protocols, returns a new object that records each call to underlying
protocol functions, then proxies to the original implementation. The returned object also implements `Spy`, which
exposes those calls. If an explicit list of protocols is not given, the list will be inferred from the given object.
For spies with added implementation, see [[mock]]. For queryies against spies, see [[call-count]] and [[received?]].
sourceraw docstring

spy?clj

(spy? s)

True if s reifies Spy.

True if s reifies Spy.
sourceraw docstring

Stubcljprotocol

A protocol shared by stubs.

A protocol shared by stubs.

all-stubsclj

(all-stubs t)

Returns a normalized hashmap of all known stubs prior to reification.

Returns a normalized hashmap of all known stubs prior to reification.
sourceraw docstring

stubclj

(stub & protos-and-impls)

Given a variable number of protocols, each followed by an optional hashmap of simple implementations, returns a new object implementing those protocols. Where no function implementation is provided, calls to that protocol function will return nil rather than raising IllegalArgumentException. Functions as values are not supported, as they require side effects to define; for more complex stubs, prefer using reify. For stubs with call count recording, use mock.

Given a variable number of protocols, each followed by an optional hashmap of simple implementations, returns a new
object implementing those protocols. Where no function implementation is provided, calls to that protocol function
will return `nil` rather than raising `IllegalArgumentException`. Functions as values are not supported, as they
require side effects to define; for more complex stubs, prefer using `reify`. For stubs with call count recording,
use [[mock]].
sourceraw docstring

stub?clj

(stub? s)

True if s reifies Stub.

True if s reifies Stub.
sourceraw docstring

throwsclj

(throws throwable-class & args)

Given a class and a list of constructor args, returns an object that, when used as part of a stub construct, will create and then throw a Throwable of the given type, constructed with the given args.

Given a class and a list of constructor args, returns an object that, when used as part of a [[stub]] construct, will
create and then throw a Throwable of the given type, constructed with the given args.
sourceraw docstring

unique-list-of-all-sig-names-and-arglistsclj

(unique-list-of-all-sig-names-and-arglists proto)
source

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

× close