branch: elpa/clojure-mode
commit d7c849137fb130110be6ae9cd8f41f230ac06d72
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-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-mode-util-test.el | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el
index bd5033506a..6a5f24ce48 100644
--- a/test/clojure-mode-util-test.el
+++ b/test/clojure-mode-util-test.el
@@ -85,24 +85,23 @@
:to-equal subdir)))))
(describe "clojure-project-relative-path"
- (cl-letf (((symbol-function 'clojure-project-dir) (lambda () project-dir)))
- (expect (string= (clojure-project-relative-path clj-file-path)
- project-relative-clj-file-path))))
+ (it "returns the path relative to the project root"
+ (spy-on 'clojure-project-dir :and-return-value project-dir)
+ (expect (clojure-project-relative-path clj-file-path)
+ :to-equal project-relative-clj-file-path)))
(describe "clojure-expected-ns"
(it "should return the namespace matching a path"
- (cl-letf (((symbol-function 'clojure-project-relative-path)
- (lambda (&optional _current-buffer-file-name)
- project-relative-clj-file-path)))
- (expect (string= (clojure-expected-ns clj-file-path) clj-file-ns))))
+ (spy-on 'clojure-project-relative-path
+ :and-return-value project-relative-clj-file-path)
+ (expect (string= (clojure-expected-ns clj-file-path) clj-file-ns)))
(it "should return the namespace even without a path"
- (cl-letf (((symbol-function 'clojure-project-relative-path)
- (lambda (&optional _current-buffer-file-name)
- project-relative-clj-file-path)))
- (expect (string= (let ((buffer-file-name clj-file-path))
- (clojure-expected-ns))
- clj-file-ns))))))
+ (spy-on 'clojure-project-relative-path
+ :and-return-value project-relative-clj-file-path)
+ (expect (string= (let ((buffer-file-name clj-file-path))
+ (clojure-expected-ns))
+ clj-file-ns)))))
(describe "clojure-find-ns"
(it "should find common namespace declarations"