diff --git a/test/ChangeLog b/test/ChangeLog index 86f3019..c59c3cb 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,11 @@ +2012-08-10 Dmitry Gutov + + * automated/ruby-mode-tests.el (ruby-should-indent): Add + docstring, check (current-indentation) instead of (current-column). + (ruby-should-indent-buffer): New function. + Add tests for `ruby-deep-indent-paren' behavior. + Port all tests from test/misc/test_ruby_mode.rb in Ruby repo. + 2012-08-09 Dmitry Gutov * automated/ruby-mode-tests.el (ruby-should-indent) diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index fbe1b8d..f91b6e4 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -24,11 +24,24 @@ (require 'ruby-mode) (defun ruby-should-indent (content column) + "Assert indentation COLUMN on the last line of CONTENT." (with-temp-buffer (insert content) (ruby-mode) (ruby-indent-line) - (should (= (current-column) column)))) + (should (= (current-indentation) column)))) + +(defun ruby-should-indent-buffer (expected content) + "Assert that CONTENT turns into EXPECTED after the buffer is re-indented. + +The whitespace before and including \"|\" on each line is removed." + (with-temp-buffer + (cl-flet ((fix-indent (s) (replace-regexp-in-string "^[ \t]*|" "" s))) + (insert (fix-indent content)) + (ruby-mode) + (indent-region (point-min) (point-max)) + (should (string= (fix-indent expected) (buffer-substring-no-properties + (point-min) (point-max))))))) (defun ruby-assert-state (content &rest values-plist) "Assert syntax state values at the end of CONTENT. @@ -57,6 +70,127 @@ VALUES-PLIST is a list with alternating index and value elements." (ruby-assert-state "foo <