From e314276c96bcc6d14ac41f70f3a747cc2e25e683 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Fri, 31 Oct 2014 02:07:57 -0400 Subject: Test bog-prepare-bib-file in temporary directory --- bog-tests.el | 70 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/bog-tests.el b/bog-tests.el index c1c98a2..3bc5781 100644 --- a/bog-tests.el +++ b/bog-tests.el @@ -229,42 +229,48 @@ ;; `bog-prepare-bib-file' (ert-deftest bog-prepare-bib-file () - (let ((temp-file (make-temp-file "bog-testing-" nil ".bib")) - (citekey "name2010word")) - (with-current-buffer (find-file-noselect temp-file) - (insert (format "\n@article{%s,\n" citekey) - "title = {A title},\n" - "author = {Last, First},\n" - "journal = {Some journal},\n" - "year = 2009,\n" - "\n}") + (bog-tests--with-temp-dir + (let ((temp-file (make-temp-file + (expand-file-name "bog-testing-" default-directory) + nil ".bib")) + (citekey "name2010word")) + (with-current-buffer (find-file-noselect temp-file) + (insert (format "\n@article{%s,\n" citekey) + "title = {A title},\n" + "author = {Last, First},\n" + "journal = {Some journal},\n" + "year = 2009,\n" + "\n}") (save-buffer)) - (kill-buffer (get-file-buffer temp-file)) - (bog-prepare-bib-file temp-file) - (should-not (file-exists-p temp-file)) - (let* ((new-file (expand-file-name (concat citekey ".bib") "/tmp")) - (new-buffer (get-file-buffer new-file))) - (should-not new-buffer) - (delete-file new-file)))) + (kill-buffer (get-file-buffer temp-file)) + (bog-prepare-bib-file temp-file) + (should-not (file-exists-p temp-file)) + (let* ((new-file (concat citekey ".bib")) + (new-buffer (get-file-buffer new-file))) + (should-not new-buffer) + (delete-file new-file))))) (ert-deftest bog-prepare-bib-file-was-open () - (let ((temp-file (make-temp-file "bog-testing-" nil ".bib")) - (citekey "name2010word")) - (with-current-buffer (find-file-noselect temp-file) - (insert (format "\n@article{%s,\n" citekey) - "title = {A title},\n" - "author = {Last, First},\n" - "journal = {Some journal},\n" - "year = 2009,\n" - "\n}") + (bog-tests--with-temp-dir + (let ((temp-file (make-temp-file + (expand-file-name "bog-testing-" default-directory) + nil ".bib")) + (citekey "name2010word")) + (with-current-buffer (find-file-noselect temp-file) + (insert (format "\n@article{%s,\n" citekey) + "title = {A title},\n" + "author = {Last, First},\n" + "journal = {Some journal},\n" + "year = 2009,\n" + "\n}") (save-buffer)) - (bog-prepare-bib-file temp-file) - (should-not (file-exists-p temp-file)) - (let* ((new-file (expand-file-name (concat citekey ".bib") "/tmp")) - (new-buffer (get-file-buffer new-file))) - (should new-buffer) - (kill-buffer new-buffer) - (delete-file new-file)))) + (bog-prepare-bib-file temp-file) + (should-not (file-exists-p temp-file)) + (let* ((new-file (concat citekey ".bib")) + (new-buffer (get-file-buffer new-file))) + (should new-buffer) + (kill-buffer new-buffer) + (delete-file new-file))))) ;; `bog-collect-references' -- cgit v1.2.3