Skip to content
This repository
Browse code

Adding an integration test for namespace replacement.

  • Loading branch information...
commit 43a7270920bb0ba4cf78401cf68cda05c200acc7 1 parent b186394
Tom Crayford authored
2  src/clojure_refactoring/support/replace.clj
@@ -14,7 +14,7 @@
14 14
   "Builds a replacement map for emacs for a given namespace"
15 15
   {:file (filename-from-ns ns)
16 16
    :new-source (parsley-to-string
17  
-                (f (:parsley (parsley-from-cache ns))))})
  17
+                (map f (parsley-from-cache ns)))})
18 18
 
19 19
 (defn replace-namespaces [namespaces f]
20 20
   "Replaces vars by calling f on each one."
2  src/clojure_refactoring/support/source.clj
@@ -84,7 +84,7 @@
84 84
     (new-ns-entry namespace-name)))
85 85
 
86 86
 (defn parsley-from-cache [namespace-name]
87  
-  (:parsley entry-from-ns-cache))
  87
+  (:parsley (entry-from-ns-cache namespace-name)))
88 88
 
89 89
 (defn add-to-ns-cache! [ns]
90 90
   (swap! ns-cache assoc (force-ns-name ns) (new-ns-entry ns)))
9  test/clojure_refactoring/support/replace_test.clj
@@ -3,6 +3,7 @@
3 3
   (:use [clojure-refactoring.support source parsley
4 4
          paths])
5 5
   (:use clojure.test)
  6
+  (:use clojure-refactoring.test-helpers)
6 7
   (:use clojure.contrib.mock))
7 8
 
8 9
 (use-fixtures :once #(time (%)))
@@ -40,3 +41,11 @@
40 41
     map-to-alist (times 1 (returns :replacement-alist))
41 42
     build-replacement-map (times 1 (returns :replacement-map))]
42 43
    (is (= (replace-callers 'a replace-test-fn) [:replacement-alist]))))
  44
+
  45
+(deftest replace_namespaces
  46
+  (doseq [namespace (find-ns-in-user-dir)]
  47
+    (let [source (slurp (filename-from-ns namespace))]
  48
+      (is (= source
  49
+             (:new-source (build-replacement-map namespace identity)))))))
  50
+
  51
+

0 notes on commit 43a7270

Please sign in to comment.
Something went wrong with that request. Please try again.