-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support so that should assertion in focus will get run in the s…
…ame manner as a test unit test.
- Loading branch information
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
;;; rails-shoulda.el --- emacs-rails integraions with should plugin. | ||
|
||
;; Copyright (C) 2006 Dmitry Galinsky <dima dot exe at gmail dot com> | ||
;; Authors: Dmitry Galinsky <dima dot exe at gmail dot com>, | ||
;; Keywords: ruby rails languages oop | ||
|
||
|
||
;;; License | ||
|
||
;; This program is free software; you can redistribute it and/or | ||
;; modify it under the terms of the GNU General Public License | ||
;; as published by the Free Software Foundation; either version 2 | ||
;; of the License, or (at your option) any later version. | ||
|
||
;; This program is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
|
||
;; You should have received a copy of the GNU General Public License | ||
;; along with this program; if not, write to the Free Software | ||
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
|
||
|
||
(defun rails-shoulda:current-test () | ||
"Return the test name based on point" | ||
(save-excursion | ||
(ruby-end-of-block) | ||
(let ((should (when (search-backward-regexp "^[ ]*should \"\\([a-z0-9_ ]+\\)\"[ ]*do" nil t) | ||
(match-string-no-properties 1))) | ||
(context (when (search-backward-regexp "^[ ]*context \"\\([a-z0-9_ ]+\\)\"[ ]*do" nil t) | ||
(match-string-no-properties 1)))) | ||
(when (and should context) | ||
(concat context " should " should))))) | ||
|
||
|
||
(defun rails-shoulda:run-current-should () | ||
"Run should assertion based on the location of point." | ||
(interactive) | ||
(let ((file (substring (buffer-file-name) (length (rails-project:root)))) | ||
(method (replace-regexp-in-string "[\+\. \'\"\(\)]" "." (rails-shoulda:current-test)))) | ||
(when method | ||
(rails-test:run-single-file file (format "--name=/%s/" method))))) | ||
|
||
|
||
|
||
|
||
(provide 'rails-shoulda) |
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