I had to revisit my test stubbing/expectation code after the recent
changes to test-is. The good news is, because of the excellent change
to make "is" a multi-method, the expectation code easily fits into
test-is. The following patch adds a new assertion for is, (is
(called?))
;; creates a stub function, binds it to an existing var and asserts
;; the stub fn was called the correct number of times.
(is (called? [[user/foo :times 2 :returns 42]
[user/bar :times 1 :returns 3]]
(user/foo x y z)
(user/bar z)))
Inside of the called? block, user/foo and user/bar are rebound to stub
functions, and then asserts that each function is called the proper
number of times. Currently, the only two options an expectation takes
are :times and :returns. I expect that more will be needed.
http://groups.google.com/group/clojure/web/test_is_called.patch
Allen