Skip to content

Commit

Permalink
add test for in-project
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjudd committed Nov 20, 2012
1 parent 4bda46d commit 59b3c2a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test-project/test/leinjacker/eval_test.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
'(spit ".test-output" (System/getenv "LEIN_VERSION"))) '(spit ".test-output" (System/getenv "LEIN_VERSION")))
(str (first (slurp ".test-output"))) => (.toString lein-gen)) (str (first (slurp ".test-output"))) => (.toString lein-gen))


(fact "in-project should work."
(in-project (utils/read-lein-project) [version (System/getenv "LEIN_VERSION")]
(spit ".test-output" version))
(str (first (slurp ".test-output"))) => (.toString lein-gen))

(fact "deprecated eval-in-project should work." (fact "deprecated eval-in-project should work."
(dep-eip/eval-in-project (dep-eip/eval-in-project
(utils/read-lein-project) (utils/read-lein-project)
Expand All @@ -23,13 +28,13 @@
(fact "sh should work." (fact "sh should work."
(sh "./bin/sh-test" ".test-output" "success") (sh "./bin/sh-test" ".test-output" "success")
(slurp ".test-output") => "success") (slurp ".test-output") => "success")

;This test should be last since it hooks eip and doesn't clean up ;This test should be last since it hooks eip and doesn't clean up
(fact "we should be able to hook eval-in-project" (fact "we should be able to hook eval-in-project"
(let [my-form '(do (let [my-form '(do
(in-ns 'foo.bar) (in-ns 'foo.bar)
(spit ".test-output" (with-out-str (spit ".test-output" (with-out-str
((resolve 'pprint) "success")))) ((resolve 'pprint) "success"))))
ran-form (atom nil)] ran-form (atom nil)]
(hook-eval-in-project (hook-eval-in-project
(fn [original-eip project form init] (fn [original-eip project form init]
Expand All @@ -41,6 +46,6 @@
'(do (let [old-ns *ns*] '(do (let [old-ns *ns*]
(ns foo.bar) (ns foo.bar)
(clojure.core/use 'clojure.pprint) (clojure.core/use 'clojure.pprint)
(in-ns (symbol (ns-name old-ns)))))) (in-ns (symbol (ns-name old-ns))))))
@ran-form => my-form @ran-form => my-form
(slurp ".test-output") => "\"success\"\n"))) (slurp ".test-output") => "\"success\"\n")))

0 comments on commit 59b3c2a

Please sign in to comment.