API for atticus.mock
by
Unknown
Usage:
(ns your-namespace
(:require atticus.mock))
Overview
Simple Mocking in Clojure. Allows you to implement the mock function as a
lambda.
(deftest with-1-test
(expects
[(f [arg] (is (= arg 1) "Check argument") arg)]
(is (= 1 (f 1)) "Call mocked function")))
(deftest with-1-once-test
(expects
[(f [arg] (once (inc arg)))]
(is (= 1 (f 1)) "Call mocked function")))
(deftest with-1-times-test
(expects
[(f [arg] (times 2 arg))]
(is (= 1 (f 1)) "Call mocked function")
(is (= 1 (f 1)) "Call mocked function")))
Public Variables and Functions
add-expectation
function
Usage: (add-expectation f)
Add an expectation check function to the list of expectations
Source
add-mock
function
Usage: (add-mock mocks mock)
Add a mock to the bindings.
Source
construct-bindings
function
Usage: (construct-bindings mocks)
Construct a binding vector from the mock specification.
Source
construct-mock
function
Usage: (construct-mock [v args & body])
Construct the mock. Checks for a mock wrapper around the body.
Source
expects
macro
Usage: (expects mocks & body)
Binds a list of mocks, checling any expectations on exit of the block.
Source
once
macro
Usage: (once v args body)
Add an expectation that the function is called once.
Source
times
macro
Usage: (times v args body)
Add an expectation that the function is called specified number of times.
Source