Created
June 3, 2011 14:20
-
-
Save diasjorge/1006410 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/rinari.el b/rinari.el | |
index f74494b..febdd5f 100644 | |
--- a/rinari.el | |
+++ b/rinari.el | |
@@ -195,10 +195,15 @@ argument allows editing of the test command arguments." | |
(or (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)) | |
+ (let* ((funname (rinari-test-function-name)) | |
(fn (and funname | |
- (string-match "#\\(.*\\)" funname) | |
- (match-string 1 funname))) | |
+ (or | |
+ (and (string-match "#\\(.*\\)" funname) | |
+ (and (not (string-equal (match-string 1 funname) "setup")) | |
+ (match-string 1 funname))) | |
+ (and (string-match "[\"']\\(.*\\)[\"']" funname) | |
+ (replace-regexp-in-string "[ ]+" "_" | |
+ (match-string 1 funname)))))) | |
(path (buffer-file-name)) | |
(ruby-options (list "-I" (expand-file-name "test" (rinari-root)) path)) | |
(default-command (mapconcat | |
@@ -211,6 +216,19 @@ 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() | |
+ (let (funname str) | |
+ (progn | |
+ (setq str (buffer-substring-no-properties | |
+ (line-beginning-position) (line-end-position))) | |
+ (if (string-match | |
+ (concat "^[ \t]*test[ \t]+" | |
+ "\\([\"'].*[\"']\\)" | |
+ "[ \t]*do" ) | |
+ str) | |
+ (setq funname (match-string 1 str)) | |
+ (setq funname (ruby-add-log-current-method)))))) | |
+ | |
(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 | |
@@ -270,11 +288,11 @@ from your conf/database.sql file." | |
(server (or (cdr (assoc "host" database-alist)) "localhost")) | |
(port (cdr (assoc "port" database-alist))) | |
(sql-server (if port (concat server ":" port) server))) | |
- (cond ((string-match "mysql" adapter) | |
+ (cond ((string-match "mysql" adapter) | |
(setf adapter "mysql")) | |
- ((string-match "sqlite" adapter) | |
+ ((string-match "sqlite" adapter) | |
(setf adapter "sqlite")) | |
- ((string-match "postgresql" adapter) | |
+ ((string-match "postgresql" adapter) | |
(setf adapter "postgres"))) | |
(eval (list (intern (concat "sql-" adapter)))) | |
(rename-buffer (sql-name environment)) (rinari-launch)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jorge - can you try out this alternate formulation please? - https://gist.github.com/1017754