Skip to content

Commit

Permalink
Extend rinari-test to support 'test "blahblah" do ...' syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
purcell committed Jun 17, 2011
1 parent 1c3460f commit a93626c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions rinari.el
Expand Up @@ -192,14 +192,12 @@ test, then try to jump to the related test using
jumping between errors and source code. With optional prefix
argument allows editing of the test command arguments."
(interactive "P")
(or (string-match "test" (or (ruby-add-log-current-method)
(or (rinari-test-function-name)
(string-match "test" (or (ruby-add-log-current-method)
(file-name-nondirectory (buffer-file-name))))
(rinari-find-test))
(let* ((funname (ruby-add-log-current-method))
(fn (and funname
(string-match "#\\(.*\\)" funname)
(match-string 1 funname)))
(path (buffer-file-name))
(let* ((fn (rinari-test-function-name))
(path (buffer-file-name))
(ruby-options (list "-I" (expand-file-name "test" (rinari-root)) path))
(default-command (mapconcat
'identity
Expand All @@ -211,6 +209,18 @@ argument allows editing of the test command arguments."
(if path (ruby-compilation-run command ruby-options)
(message "no test available"))))

(defun rinari-test-function-name()
(save-excursion
(if (re-search-backward (concat "^[ \t]*\\(def\\|test\\)[ \t]+"
"\\([\"'].*?[\"']\\|" ruby-symbol-re "*\\)"
"[ \t]*") nil t)
(let ((name (match-string 2)))
(if (string-match "^[\"']\\(.*\\)[\"']$" name)
(replace-regexp-in-string " +" "_" (match-string 1 name))
(if (string-match "^test" name)
name))))))


(defun rinari-console (&optional edit-cmd-args)
"Runs a Rails console in a compilation buffer, with command history
and links between errors and source code. With optional prefix
Expand Down

0 comments on commit a93626c

Please sign in to comment.