diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-10-31 02:07:57 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-10-31 02:07:57 -0400 |
commit | e314276c96bcc6d14ac41f70f3a747cc2e25e683 (patch) | |
tree | 4bd90f863e9853c3dd3567009a279a54312a3d32 | |
parent | 08d71bf1b687f6cd9be78489369a8e276714f808 (diff) | |
download | bog-e314276c96bcc6d14ac41f70f3a747cc2e25e683.tar.gz |
Test bog-prepare-bib-file in temporary directory
-rw-r--r-- | bog-tests.el | 70 |
1 files 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' |