While it is easy to run the whole test suite with
projectile-rails, this takes too much time. I'd like to be able to run the current test (i.e., the test point is located in) with a shortcut. Is this possible?
This way it works:
(defun get-current-test-name () (save-excursion (let ((pos) (test-name)) (re-search-backward "test \"\\([^\"]+\\)\" do") (setq test-name (buffer-substring-no-properties (match-beginning 1) (match-end 1))) (concat "test_" (replace-regexp-in-string " " "_" test-name))))) (defun run-test-at-point () (interactive) (let ((root-dir (projectile-project-root))) (compile (format "ruby -Ilib:test -I%s/test %s -n %s" root-dir (expand-file-name (buffer-file-name)) (get-current-test-name)))))