1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-15 09:47:20 +00:00

Convert manual indent test for ruby-mode into unit test

* test/manual/indent/ruby.rb: Move from here...
* test/lisp/progmodes/ruby-mode-resources/ruby.rb: ...to here.

* test/lisp/progmodes/ruby-mode-tests.el
(ruby-mode-tests-data-dir): New variable.
(ruby--indent/converted-from-manual-test): New test.
This commit is contained in:
Stefan Kangas 2020-09-21 17:41:45 +02:00
parent 1d98bed6c3
commit b63c3535b0
2 changed files with 19 additions and 0 deletions

View File

@ -24,6 +24,12 @@
(require 'ert)
(require 'ruby-mode)
(defvar ruby-mode-tests-data-dir
(file-truename
(expand-file-name "ruby-mode-resources/"
(file-name-directory (or load-file-name
buffer-file-name)))))
(defmacro ruby-with-temp-buffer (contents &rest body)
(declare (indent 1) (debug t))
`(with-temp-buffer
@ -842,6 +848,19 @@ VALUES-PLIST is a list with alternating index and value elements."
(ruby--insert-coding-comment "utf-8")
(should (string= "# encoding: utf-8\n\n" (buffer-string))))))
;; TODO: Convert these into unit proper tests instead of using an
;; external file.
(ert-deftest ruby--indent/converted-from-manual-test ()
:tags '(:expensive-test)
;; Converted from manual test.
(let ((buf (find-file-noselect (expand-file-name "ruby.rb"
ruby-mode-tests-data-dir))))
(unwind-protect
(with-current-buffer buf
(let ((orig (buffer-string)))
(indent-region (point-min) (point-max))
(should (equal (buffer-string) orig))))
(kill-buffer buf))))
(provide 'ruby-mode-tests)