Skip to content

Instantly share code, notes, and snippets.

@tmaeda
Created June 7, 2009 16:13
Show Gist options
  • Save tmaeda/125383 to your computer and use it in GitHub Desktop.
Save tmaeda/125383 to your computer and use it in GitHub Desktop.
emacs-rails 2.3.2 test
;; 2.3.2 test
(defun rails-core:current-test-name ()
(save-excursion
(when (search-backward-regexp "^[ ]*test[ ]*\"\\([a-z0-9_ ]+\\)\"" nil t)
(format "test_%s"
(replace-regexp-in-string " " "_" (match-string-no-properties 1))
))))
(defun rails-test:run-current-method ()
"Run a test for the current method."
(interactive)
(let ((file (substring (buffer-file-name) (length (rails-project:root))))
(method (rails-core:current-test-name)))
(when method
(rails-test:run-single-file file (format "--name=%s" method)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment