emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master a5e88b2 34/40: Add test for snippet saving


From: Noam Postavsky
Subject: [elpa] master a5e88b2 34/40: Add test for snippet saving
Date: Wed, 26 Oct 2016 23:06:34 +0000 (UTC)

branch: master
commit a5e88b2fd423791bc9827e48e0c15d69d17ee0b4
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Add test for snippet saving
    
    * yasnippet-tests.el (snippet-save): New test.
---
 yasnippet-tests.el |   35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 55cd137..48d20fa 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -634,6 +634,39 @@ TODO: correct this bug!"
      (should (null (key-binding "\C-c1")))
      (should (equal (yas-lookup-snippet "won") "one!")))))
 
+(ert-deftest snippet-save ()
+  "Make sure snippets can be saved correctly."
+  (yas-saving-variables
+   (yas-with-snippet-dirs
+    '((".emacs.d/snippets"
+       ("text-mode")))
+    (letf (((symbol-function 'y-or-n-p) (lambda (&rest _) t))
+           ((symbol-function 'read-file-name)
+            (lambda (_prompt &optional _dir _default _mustmatch initial 
_predicate)
+              (expand-file-name initial)))
+           ((symbol-function 'completing-read)
+            (lambda (_prompt collection &rest _)
+              (or (car collection) ""))))
+      (with-temp-buffer
+        (text-mode)
+        (yas-minor-mode +1)
+        (save-current-buffer
+          (yas-new-snippet t)
+          (with-current-buffer "*new snippet*"
+            (snippet-mode)
+            (insert "# name: foo\n# key: bar\n# --\nsnippet foo")
+            (call-interactively 'yas-load-snippet-buffer-and-close)))
+        (save-current-buffer
+          (yas-new-snippet t)
+          (with-current-buffer "*new snippet*"
+            (snippet-mode)
+            (insert "# name: bar\n# key: bar\n# --\nsnippet bar")
+            (call-interactively 'yas-load-snippet-buffer-and-close)))
+        (should (file-readable-p
+                 (expand-file-name "foo" (car yas-snippet-dirs))))
+        (should (file-readable-p
+                 (expand-file-name "bar" (car yas-snippet-dirs)))))))))
+
 (ert-deftest visiting-compiled-snippets ()
   "Test snippet visiting for compiled snippets."
   (yas-with-some-interesting-snippet-dirs
@@ -1018,7 +1051,7 @@ add the snippets associated with the given mode."
 
 (defun yas-call-with-snippet-dirs (dirs fn)
   (let* ((default-directory (make-temp-file "yasnippet-fixture" t))
-         (yas-snippet-dirs (mapcar #'car dirs)))
+         (yas-snippet-dirs (mapcar (lambda (d) (expand-file-name (car d))) 
dirs)))
     (with-temp-message ""
       (unwind-protect
           (progn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]