]> git.eshelyaron.com Git - emacs.git/commitdiff
* test/automated/ruby-mode-tests.el:
authorBozhidar Batsov <bozhidar@batsov.com>
Wed, 20 Nov 2013 11:51:12 +0000 (13:51 +0200)
committerBozhidar Batsov <bozhidar@batsov.com>
Wed, 20 Nov 2013 11:51:12 +0000 (13:51 +0200)
Add a few tests for `ruby--insert-coding-comment'.

test/automated/ruby-mode-tests.el

index efed67d9d914d1645be86bbdadc841a50c560fa5..9c12116975633a7b5adf89367040222ca4a75af3 100644 (file)
@@ -619,6 +619,26 @@ VALUES-PLIST is a list with alternating index and value elements."
     (ruby-backward-sexp)
     (should (= 2 (line-number-at-pos)))))
 
+(ert-deftest ruby--insert-coding-comment-ruby-style ()
+  (with-temp-buffer
+    (let ((ruby-encoding-magic-comment-style 'ruby))
+      (ruby--insert-coding-comment "utf-8")
+      (should (string= "# coding: utf-8\n" (buffer-string))))))
+
+(ert-deftest ruby--insert-coding-comment-emacs-style ()
+  (with-temp-buffer
+    (let ((ruby-encoding-magic-comment-style 'emacs))
+      (ruby--insert-coding-comment "utf-8")
+      (should (string= "# -*- coding: utf-8 -*-\n" (buffer-string))))))
+
+(ert-deftest ruby--insert-coding-comment-custom-style ()
+  (with-temp-buffer
+    (let ((ruby-encoding-magic-comment-style 'custom)
+          (ruby-custom-encoding-magic-comment-template "# encoding: %s\n"))
+      (ruby--insert-coding-comment "utf-8")
+      (should (string= "# encoding: utf-8\n\n" (buffer-string))))))
+
+
 (provide 'ruby-mode-tests)
 
 ;;; ruby-mode-tests.el ends here