Permalink
Browse files

Add comment spec tests

  • Loading branch information...
1 parent 9b871da commit 22631b88ba065dd04d27690d2532f9b992f711b0 @fhd committed Dec 18, 2011
Showing with 37 additions and 2 deletions.
  1. +2 −2 .gitmodules
  2. +5 −0 pom.xml
  3. +30 −0 src/test/clojure/clostache/test_specs.clj
  4. 0 { → src/test/resources}/spec
View
4 .gitmodules
@@ -1,3 +1,3 @@
-[submodule "spec"]
- path = spec
+[submodule "src/test/resources/spec"]
+ path = src/test/resources/spec
url = https://github.com/mustache/spec
View
5 pom.xml
@@ -48,6 +48,11 @@
<artifactId>jline</artifactId>
<version>0.9.94</version>
</dependency>
+ <dependency>
+ <groupId>clj-yaml</groupId>
+ <artifactId>clj-yaml</artifactId>
+ <version>0.3.1</version>
+ </dependency>
</dependencies>
<build>
<sourceDirectory>src/main/clojure</sourceDirectory>
View
30 src/test/clojure/clostache/test_specs.clj
@@ -0,0 +1,30 @@
+(ns clostache.test-specs
+ (:use clojure.test
+ clostache.parser)
+ (:require [clj-yaml.core :as yaml]))
+
+(defn- load-spec-tests [spec]
+ (let [path (-> (Thread/currentThread)
+ (.getContextClassLoader)
+ (.getResourceAsStream (str "spec/specs/" spec ".yml")))
+ data (yaml/parse-string (slurp path))]
+ (:tests data)))
+
+(defn run-spec-test [spec-test]
+ (is (= (:expected spec-test)
+ (render (:template spec-test) (:data spec-test)))
+ (str (:name spec-test) ": " (:desc spec-test))))
+
+(defn run-spec-tests [spec]
+ (doseq [spec-test (load-spec-tests spec)]
+ (run-spec-test spec-test)))
+
+(deftest test-comments
+ (run-spec-tests "comments"))
+
+;; TODO: Test the following specs:
+;; - delimiters
+;; - interpolation
+;; - inverted
+;; - sections
+;; - partials
View
0 spec → src/test/resources/spec
File renamed without changes.

0 comments on commit 22631b8

Please sign in to comment.