diff options
| author | Bozhidar Batsov <bozhidar@batsov.com> | 2018-10-01 16:52:55 +0300 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.com> | 2018-10-01 16:52:55 +0300 |
| commit | b99f023b3ca48beae9104e81f7466487762e46d4 (patch) | |
| tree | a334f978ba743afff802f429eb239c20d186571d | |
| parent | 1fe7634dd1317b685d2e47dbe1861271984908ad (diff) | |
Move a couple of util macros over to our new buttercup tests
| -rw-r--r-- | test/projectile-test.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el index d876800..280230d 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -28,6 +28,33 @@ (require 'projectile) (require 'buttercup) +;;; Test Utilities +(defmacro projectile-test-with-sandbox (&rest body) + "Evaluate BODY in an empty temporary directory." + (declare (indent 0) (debug (&rest form))) + `(let ((sandbox (expand-file-name + (convert-standard-filename "test/sandbox/") + (file-name-directory (locate-library "projectile.el" t))))) + (when (file-directory-p sandbox) + (delete-directory sandbox t)) + (make-directory sandbox t) + (let ((default-directory sandbox)) + ,@body))) + +(defmacro projectile-test-with-files (files &rest body) + "Evaluate BODY in the presence of FILES. + +You'd normally combine this with `projectile-test-with-sandbox'." + (declare (indent 1) (debug (sexp &rest form))) + `(progn + ,@(mapcar (lambda (file) + (if (string-suffix-p "/" file) + `(make-directory ,file t) + `(with-temp-file ,file))) + files) + ,@body)) + +;;; Tests (describe "projectile-prepend-project-name" (it "prepends the project name to its parameter" (spy-on 'projectile-project-name :and-return-value "project") |
