aboutsummaryrefslogtreecommitdiff
path: root/modules/mock/src/test/clojure
diff options
context:
space:
mode:
authorMatt Clark <matt.clark.1@gmail.com>2010-08-26 21:28:34 -0300
committerMatt Clark <matt.clark.1@gmail.com>2010-08-26 21:45:40 -0300
commit636381148b53424c0ea98f5983a2d1574451c6ee (patch)
tree1f0a551d15d29f53f1b818554c260c15fd6feee8 /modules/mock/src/test/clojure
parent28689c48fa35c34023360aa2724b47ee1eb14e4e (diff)
Added :pre to functions instead of using custom assert-args macro in c.c.mock Cleaned up c.c.mock documentation
Removed map? preconditions on mock functions which was causing tests to fail updated copyright notices for mock improved mock namespace description Fixed line endings which were erroneously CRLF instead of LF
Diffstat (limited to 'modules/mock/src/test/clojure')
-rw-r--r--modules/mock/src/test/clojure/clojure/contrib/mock/test_adapter.clj52
1 files changed, 16 insertions, 36 deletions
diff --git a/modules/mock/src/test/clojure/clojure/contrib/mock/test_adapter.clj b/modules/mock/src/test/clojure/clojure/contrib/mock/test_adapter.clj
index 466cb537..5f21ce11 100644
--- a/modules/mock/src/test/clojure/clojure/contrib/mock/test_adapter.clj
+++ b/modules/mock/src/test/clojure/clojure/contrib/mock/test_adapter.clj
@@ -1,38 +1,18 @@
-;;; test_adapter.clj: clojure.test adapter for mocking/expectation framework for Clojure
-
-;; by Matt Clark
-
-;; Copyright (c) Matt Clark, 2009. All rights reserved. The use
-;; and distribution terms for this software are covered by the Eclipse
-;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php).
-;; By using this software in any fashion, you are
-;; agreeing to be bound by the terms of this license. You must not
-;; remove this notice, or any other, from this software.
-
-(ns clojure.contrib.mock.test-adapter
- (:require [clojure.contrib.mock :as mock])
- (:use clojure.test
- clojure.contrib.ns-utils))
-
-(immigrate 'clojure.contrib.mock)
-
-(defn report-problem
- "This function is designed to be used in a binding macro to override
-the report-problem function in clojure.contrib.mock. Instead of printing
-the error to the console, the error is logged via clojure.test."
- {:dynamic true}
- [fn-name expected actual msg]
- (report {:type :fail,
- :message (str msg " Function name: " fn-name),
- :expected expected,
- :actual actual}))
-
-
-(defmacro expect [& body]
- "Use this macro instead of the standard c.c.mock expect macro to have
-failures reported through clojure.test."
- `(binding [mock/report-problem report-problem]
- (mock/expect ~@body)))
-
+(ns clojure.contrib.test-contrib.mock-test.test-adapter-test
+ (:use clojure.contrib.mock.test-adapter
+ [clojure.contrib.test-contrib.mock-test :only (assert-called)]
+ clojure.test))
+
+(deftest test-report-problem-called
+ (def #^{:private true :dynamic true} fn1 (fn [x] "dummy code"))
+ (def #^{:private true :dynamic true} fn2 (fn [x y] "dummy code2"))
+ (let [under-test (fn [x] (fn1 x))]
+ (assert-called clojure.contrib.mock.test-adapter/report-problem
+ true (expect [fn1 (times 5)] (under-test "hi")))))
+
+(deftest test-is-report-called
+ (assert-called clojure.test/report true
+ (clojure.contrib.mock.test-adapter/report-problem
+ 'fn-name 5 6 "fake problem")))