diff options
author | Stuart Sierra <mail@stuartsierra.com> | 2010-08-13 10:06:53 -0400 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2010-08-13 10:06:53 -0400 |
commit | 342ea417801f7d47b3f64fca329b0bbbf94fea27 (patch) | |
tree | 00213ab622d4271ce3ec2fc23fbc61ff3384c78e /modules/mock/src/test/clojure | |
parent | 53caec96320917139d44ad4ba25f52ac61cc4c23 (diff) |
Fix remaining dependency issues in modular build
Diffstat (limited to 'modules/mock/src/test/clojure')
-rw-r--r-- | modules/mock/src/test/clojure/clojure/contrib/mock/test_adapter.clj | 52 |
1 files changed, 36 insertions, 16 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 5f21ce11..466cb537 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,18 +1,38 @@ -(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"))) +;;; 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))) + |