Skip to content

Commit

Permalink
XML documents need to be able to contain text content.
Browse files Browse the repository at this point in the history
  • Loading branch information
gga committed Jun 21, 2012
1 parent ae03ec2 commit 82d06b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/janus/verify.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@
els (if (map? (first attrs-and-els))
(rest attrs-and-els)
attrs-and-els)]
(apply xml/element (concat [tag attrs] (map vec-to-el els)))))
(apply xml/element (concat [tag attrs]
(map (fn [el] (if (string? el)
el
(vec-to-el el)))
els)))))

(defn to-xml [tree]
(xml/emit-str (vec-to-el tree)))
Expand Down
4 changes: 3 additions & 1 deletion test/janus/test/verify_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
(fact
(to-xml [:tag]) => (contains "<tag></tag>")
(to-xml [:tag {:attr "value"}]) => (contains "<tag attr=\"value\">")
(to-xml [:tag [:sub]]) => (contains "<tag><sub></sub>"))
(to-xml [:tag [:sub]]) => (contains "<tag><sub></sub>")
(to-xml [:tag "blah"]) => (contains "<tag>blah</tag>")
(to-xml [:tag "blah" [:sub {:attr "val"}]]) => (contains "<tag>blah<sub attr=\"val\"></sub></tag"))

(fact
(body-from ..contract.. {}) => "data"
Expand Down

0 comments on commit 82d06b4

Please sign in to comment.