Permalink
Browse files

* rails-spec.el: base support for rspec. Function

 `rails-spec:run-all', `rails-spec:run-this-file', `rails-spec:run-last',
 `rails-spec:run-files'.  Variables: `rails-spec:all-files',
 `rails-spec:last-files', `rails-spec:runner',
 `rails-spec:runner-options'.
* rails-find.el, rails-ui.el: finds for rspec
* rails-project.el: new functions: rails-project:in-root-with-cd, 
 rails-project:compile-in-root
* rails-lib.el: new macro in-directory
									 
M    trunk/rails-lib.el
M    trunk/rails-project.el
M    trunk/rails-ui.el
M    trunk/rails-find.el
M    trunk/ChangeLog
A    trunk/rails-spec.el
M    trunk/rails.el


git-svn-id: svn+ssh://rubyforge.org/var/svn/emacs-rails/trunk@213 cc5033d0-740f-0410-afc7-949910e492f2
  • Loading branch information...
1 parent cc95737 commit 8523372f911a1852cc1f32b7d06e8f07c9ed6a0f crazypit committed Aug 24, 2007
Showing with 110 additions and 0 deletions.
  1. +11 −0 ChangeLog
  2. +7 −0 rails-find.el
  3. +9 −0 rails-lib.el
  4. +9 −0 rails-project.el
  5. +64 −0 rails-spec.el
  6. +9 −0 rails-ui.el
  7. +1 −0 rails.el
View
@@ -1,3 +1,14 @@
+2007-08-18 Peter Rezikov <crazypit13@gmail.com>
+ * rails-spec.el: base support for rspec. Function
+ `rails-spec:run-all', `rails-spec:run-this-file', `rails-spec:run-last',
+ `rails-spec:run-files'. Variables: `rails-spec:all-files',
+ `rails-spec:last-files', `rails-spec:runner',
+ `rails-spec:runner-options'.
+ * rails-find.el, rails-ui.el: finds for rspec
+ * rails-project.el: new functions: rails-project:in-root-with-cd,
+ rails-project:compile-in-root
+ * rails-lib.el: new macro in-directory
+
2007-08-18 Dmitry Galinsky <dima.exe@gmail.com>
* rails-scripts.el (rails-script:run-interactive): setup a
View
@@ -51,4 +51,11 @@
(rails-find:gen "migrate" "db/migrate")
(rails-find:gen "fixtures" "test/fixtures")
+;; Rspec
+(rails-find:gen "spec" "spec/")
+(rails-find:gen "spec-controllers" "spec/controllers/")
+(rails-find:gen "spec-models" "spec/models/")
+(rails-find:gen "spec-helpers" "spec/helpers/")
+(rails-find:gen "spec-fixtures" "spec/fixtures/")
+
(provide 'rails-find)
View
@@ -252,6 +252,15 @@ it."
"Return the parent directory of a file named FILE-NAME."
(replace-regexp-in-string "[^/]*$" "" file-name))
+(defmacro* in-directory ((directory) &rest body)
+ (let ((before-directory (gensym)))
+ `(let ((,before-directory default-directory)
+ (default-directory ,directory))
+ (cd ,directory)
+ ,@body
+ (cd ,before-directory))))
+
+
;; Buffers
(defun buffer-string-by-name (buffer-name)
View
@@ -65,6 +65,15 @@ BODY is executed."
(let ((default-dir ,root))
,@body))))
+(defmacro* rails-project:in-root-with-cd (&rest body)
+ (let ((root (gensym)))
+ `(rails-project:with-root (,root)
+ (in-directory (,root) ,@body))))
+
+(defun rails-project:compile-in-root (command)
+ (rails-project:in-root-with-cd
+ (compile command)))
+
(defun rails-project:name ()
"Return the name of current Rails project."
(replace-regexp-in-string "^.*/\\(.*\\)/$" "\\1"
View
@@ -0,0 +1,64 @@
+;;; rails-rake.el --- emacs-rails integraions with rake tasks.
+
+;; Copyright (C) 2006 Dmitry Galinsky <dima dot exe at gmail dot com>
+
+;; Authors: Dmitry Galinsky <dima dot exe at gmail dot com>,
+;; Peter Rezikov <crazypit13 at gmail dot com>
+;; Keywords: ruby rails languages oop
+;; $URL: svn+ssh://rubyforge/var/svn/emacs-rails/trunk/rails-spec.el $
+;; $Id: rails-spec.el 117 2007-03-25 23:37:37Z dimaexe $
+
+;;; 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.
+
+(defvar rails-spec:all-files "./spec"
+ "All spec files/directories in project")
+
+(defvar rails-spec:last-files rails-spec:all-files
+ "Last files that run with spec. In this variable memorized each spec coommand.")
+
+(defvar rails-spec:runner "./script/spec"
+ "Command, that run specs.")
+
+(defvar rails-spec:runner-options ""
+ "Options to spec command.")
+
+(defun rails-spec:run-files (files)
+ "Run spec for files"
+ (interactive "Mspec files: ")
+ (setf rails-spec:last-files files)
+ (let ((default-process-coding-system '(utf-8 . utf-8)))
+ (rails-project:compile-in-root
+ (concat rails-spec:runner " "
+ rails-spec:runner-options " "
+ files))))
+
+(defun rails-spec:run-this-file ()
+ "Run spec for current file"
+ (interactive)
+ (rails-spec:run-files (buffer-file-name (current-buffer))))
+
+(defun rails-spec:run-all ()
+ "Run spec for all files in project (rails-spec:all-files variable)"
+ (interactive)
+ (rails-spec:run-files rails-spec:all-files))
+
+(defun rails-spec:run-last ()
+ "Run last runned spec command"
+ (interactive)
+ (rails-spec:run-files rails-spec:last-files))
+
+(provide 'rails-spec)
View
@@ -262,12 +262,21 @@
((rails-key "\C-c f p") 'rails-find:public)
((rails-key "\C-c f f") 'rails-find:fixtures)
((rails-key "\C-c f o") 'rails-find:config)
+ ;; Spec finds
+ ((rails-key "\C-c f r s") 'rails-find:spec)
+ ((rails-key "\C-c f r c") 'rails-find:spec-controllers)
+ ((rails-key "\C-c f r m") 'rails-find:spec-models)
+ ((rails-key "\C-c f r h") 'rails-find:spec-helpers)
+ ((rails-key "\C-c f r v") 'rails-find:spec-views)
+ ((rails-key "\C-c f r f") 'rails-find:spec-fixtures)
((rails-key "\C-c d m") 'rails-rake:migrate)
((rails-key "\C-c d v") 'rails-rake:migrate-to-version)
((rails-key "\C-c d p") 'rails-rake:migrate-to-prev-version)
((rails-key "\C-c d t") 'rails-rake:clone-development-db-to-test-db)
+
+
;; Tests
((rails-key "\C-c r") 'rails-rake:task)
((rails-key "\C-c t") 'rails-test:run)
View
@@ -68,6 +68,7 @@
(require 'rails-model-layout)
(require 'rails-controller-layout)
(require 'rails-features)
+(require 'rails-spec)
;;;;;;;;;; Variable definition ;;;;;;;;;;

0 comments on commit 8523372

Please sign in to comment.