branch: elpa/clojure-ts-mode
commit 2f2da7e60eb8e1775d902586d332d73ddba8e24a
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Use spy-on instead of cl-letf for project stubs in tests
    
    Replace (cl-letf ((symbol-function ...))) with buttercup's spy-on, which
    auto-restores after each spec. The clojure-ts-project-relative-path check
    was a bare expect directly under describe (so it never ran as a spec);
    wrap it in an it, which both fixes that and lets it use spy-on.
---
 test/clojure-ts-mode-util-test.el | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/test/clojure-ts-mode-util-test.el 
b/test/clojure-ts-mode-util-test.el
index 32f9d29aa2..c2321f5636 100644
--- a/test/clojure-ts-mode-util-test.el
+++ b/test/clojure-ts-mode-util-test.el
@@ -50,25 +50,24 @@
                                :to-equal (file-name-as-directory temp-dir))))))
 
   (describe "clojure-ts-project-relative-path"
-    (cl-letf (((symbol-function 'clojure-ts-project-dir) (lambda () 
project-dir)))
+    (it "returns the path relative to the project root"
+      (spy-on 'clojure-ts-project-dir :and-return-value project-dir)
       (expect (clojure-ts-project-relative-path clj-file-path)
               :to-equal project-relative-clj-file-path)))
 
   (describe "clojure-ts-expected-ns"
     (it "should return the namespace matching a path"
-      (cl-letf (((symbol-function 'clojure-ts-project-relative-path)
-                 (lambda (&optional _current-buffer-file-name)
-                   project-relative-clj-file-path)))
-        (expect (clojure-ts-expected-ns clj-file-path)
-                :to-equal clj-file-ns)))
+      (spy-on 'clojure-ts-project-relative-path
+              :and-return-value project-relative-clj-file-path)
+      (expect (clojure-ts-expected-ns clj-file-path)
+              :to-equal clj-file-ns))
 
     (it "should return the namespace even without a path"
-      (cl-letf (((symbol-function 'clojure-ts-project-relative-path)
-                 (lambda (&optional _current-buffer-file-name)
-                   project-relative-clj-file-path)))
-        (expect (let ((buffer-file-name clj-file-path))
-                  (clojure-ts-expected-ns))
-                :to-equal clj-file-ns)))))
+      (spy-on 'clojure-ts-project-relative-path
+              :and-return-value project-relative-clj-file-path)
+      (expect (let ((buffer-file-name clj-file-path))
+                (clojure-ts-expected-ns))
+              :to-equal clj-file-ns))))
 
 (describe "clojure-ts-find-ns"
   (it "should find common namespace declarations"

Reply via email to