(fn-mock fn-symbol f-or-res)Creates a mock of a function specified by symbol. It uses mock function
to generate a mock. It resolves aliases for namespaces according to current namespace.
Creates a mock of a function specified by symbol. It uses `mock` function to generate a mock. It resolves aliases for namespaces according to current namespace.
(invoked-as? [m & args])Checks if given mock invocations were present.
Checks if given mock invocations were present.
(invoked-with? m & expected-args)Checks if mock was invoked with given args
Checks if mock was invoked with given args
(invoked? m)(invoked? m n)Checks if mock was invoked at least once, or N times.
Checks if mock was invoked at least once, or N times.
(last-args m)Returns the last recorded call's arguments.
Returns the last recorded call's arguments.
(mock)(mock f-or-res)Creates a mock function that accepts variable number of arguments and will return nil or given value and record all arguments passed to the function. If you specify function as a value, it will be executed with vector of all calls as an argument.
Creates a mock function that accepts variable number of arguments and will return nil or given value and record all arguments passed to the function. If you specify function as a value, it will be executed with vector of all calls as an argument.
(not-invoked? m)Checks if mock was never invoked.
Checks if mock was never invoked.
(return-matching & call-value-pairs)Returns a function generating returning values matching calls
Returns a function generating returning values matching calls
(return-values & values)Returns a function generating returning values in a following calls.
Returns a function generating returning values in a following calls.
(with-mocks mocks & body)This macro is a syntactic sugar for mocking specified symbols.
(with-mocks [somens/somefn x] (println (somens/somefn 10)))
will be replaced with
(with-redefs [somens/somefn (siili.memocks/fn-mock 'somens/fn-mock x)] (println (somens/somefn 10)))
This macro is a syntactic sugar for mocking specified symbols. (with-mocks [somens/somefn x] (println (somens/somefn 10))) will be replaced with (with-redefs [somens/somefn (siili.memocks/fn-mock 'somens/fn-mock x)] (println (somens/somefn 10)))
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |