From 4da361d9202db79c29096f0eec57c3bcb76e69f8 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 9 Sep 2017 14:03:47 -0700 Subject: [PATCH] 2.2.0-rc1 add `expecting` macro Like `clojure.test/testing`. --- CHANGELOG.md | 2 +- project.clj | 2 +- src/cljc/expectations/clojure/test.cljc | 8 ++++++++ test/cljc/clojure_test/clojure_test.cljc | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3501ca7..36314db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changes in version 2.2.0 -Add support for `clojure.test` via the new `expectations.clojure.test` namespace and the `defexpect` macro #82. +Add support for `clojure.test` via the new `expectations.clojure.test` namespace and the `defexpect` macro #82. Add `expecting` documentation macro (like `clojure.test/testing`). Add `approximately` predicate, to test if two floating point values are "equal" (within a given tolerance) #84. diff --git a/project.clj b/project.clj index e75735e..a516e38 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject expectations "2.2.0-beta3" +(defproject expectations "2.2.0-rc1" :description "testing framework" :jar-name "expectations.jar" :jar-exclusions [#"\.swp|\.swo|\.DS_Store"] diff --git a/src/cljc/expectations/clojure/test.cljc b/src/cljc/expectations/clojure/test.cljc index 712ecf7..f222501 100644 --- a/src/cljc/expectations/clojure/test.cljc +++ b/src/cljc/expectations/clojure/test.cljc @@ -63,5 +63,13 @@ "defexpect contains no 'expect' forms") `(clojure.test/deftest ~n ~@forms#)))) +#?(:clj + (defmacro expecting + "The Expectations version of clojure.test/testing." + [string & body] + `(binding [t/*testing-contexts* (conj t/*testing-contexts* ~string)] + ~@body))) + + #?(:clj (e/disable-run-on-shutdown)) diff --git a/test/cljc/clojure_test/clojure_test.cljc b/test/cljc/clojure_test/clojure_test.cljc index 9953ed2..e704489 100644 --- a/test/cljc/clojure_test/clojure_test.cljc +++ b/test/cljc/clojure_test/clojure_test.cljc @@ -34,8 +34,9 @@ 0 (/ 1 0)) (defexpect grouped - (expect 42 (from-each [n [41 42 43]] n)) - (expect 42 (in [41 43])) + (expecting "failures in sequence tests" + (expect 42 (from-each [n [41 42 43]] n)) + (expect 42 (in [41 43]))) (expect (more number? pos?) -1) (expect pos? -1) (expect "Hello World!" "Hello Clojure!")