diff options
author | Aaron Bedra and Stuart Halloway <pair@thinkrelevance.com> | 2009-08-23 13:09:53 -0400 |
---|---|---|
committer | Aaron Bedra and Stuart Halloway <pair@thinkrelevance.com> | 2009-08-23 13:09:53 -0400 |
commit | cf4790b017ab4d2840f9d224abfa9c6023f71262 (patch) | |
tree | 83858019c5136c5d50959f99808942701fb89dbd /src/clojure/contrib/expect/test_is_adapter.clj | |
parent | 6b763062af9568c1b069d5f86c8d5481a3fdfeea (diff) |
added test-expect source, renamed namespaces for contrib
Diffstat (limited to 'src/clojure/contrib/expect/test_is_adapter.clj')
-rw-r--r-- | src/clojure/contrib/expect/test_is_adapter.clj | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/clojure/contrib/expect/test_is_adapter.clj b/src/clojure/contrib/expect/test_is_adapter.clj new file mode 100644 index 00000000..ebe09773 --- /dev/null +++ b/src/clojure/contrib/expect/test_is_adapter.clj @@ -0,0 +1,37 @@ +;;; test_is_adapter.clj: test-is 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.expect.test-is-adapter + (:require [clojure.contrib.expect :as expect]) + (:use clojure.test + clojure.contrib.ns-utils)) + +(immigrate 'clojure.contrib.expect) + +(defn report-problem + "This function is designed to be used in a binding macro to override +the report-problem function in the test-expect namespace. Instead of printing +the error to the console, the error is logged via test-is." + [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 test-expect expect macro to have +failures reported through test-is." + `(binding [expect/report-problem report-problem] + (expect/expect ~@body))) + + + |