Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve running specs for rails 3 and capybara

  • Loading branch information...
commit c0a173c1ec8ccb04b1b6cfd94570c5f9e680c404 1 parent c5a8b9c
@remvee authored
View
3  rails-cmd-proxy.el
@@ -148,7 +148,8 @@ otherwise if set REVERSE convert from remote to local."
(defun ansi-color-insertion-filter (proc string)
(with-current-buffer (process-buffer proc)
- (let ((moving (= (point) (process-mark proc))))
+ (let ((buffer-read-only nil)
+ (moving (= (point) (process-mark proc))))
(save-excursion
;; Insert the text, advancing the process marker.
(goto-char (process-mark proc))
View
9 rails-core.el
@@ -37,6 +37,7 @@
"test/functional"
"test/fixtures"
"spec/controllers"
+ "spec/requests"
"spec/fixtures"
"spec/lib"
"spec/models"
@@ -330,8 +331,12 @@ CONTROLLER."
"Return the controller spec file name for the controller named
CONTROLLER."
(when controller
- (format "spec/controllers/%s_spec.rb"
- (rails-core:file-by-class (rails-core:long-controller-name controller) t))))
+ (let ((existing (find-if #'file-exists-p (mapcar (lambda (pattern)
+ (rails-core:file (format pattern
+ (rails-core:file-by-class controller t))))
+ '("spec/requests/%s_spec.rb"
+ "spec/controllers/%s_controller_spec.rb")))))
+ (if existing existing (rails-core:file (format "spec/controllers/%s_controller_spec.rb" (rails-core:file-by-class controller t)))))))
(defun rails-core:lib-file (lib-name)
"Return the model file from the lib name."
View
5 rails-scripts.el
@@ -167,7 +167,7 @@ For example -c to remove files from svn.")
"Run a Rails script COMMAND with PARAMETERS with
BUFFER-MAJOR-MODE and process-sentinel SENTINEL."
(unless (listp parameters)
- (error "rails-script:run PARAMETERS must be the list"))
+ (error "rails-script:run PARAMETERS must be a list"))
(rails-project:with-root
(root)
(save-some-buffers)
@@ -189,11 +189,12 @@ BUFFER-MAJOR-MODE and process-sentinel SENTINEL."
(add-hook 'after-change-functions 'rails-cmd-proxy:convert-buffer-from-remote nil t))
(set-process-coding-system proc 'utf-8-dos 'utf-8-dos)
(set-process-sentinel proc 'rails-script:sentinel-proc)
+ (set-process-filter proc 'ansi-color-insertion-filter)
(setq rails-script:running-script-name (concat command
" "
(strings-join " " parameters)))
(setq rails-ui:mode-line-script-name (or mode-line-string
- a command))
+ command))
(message "Starting %s." rails-script:running-script-name))))))
;;;;;;;;;; Destroy stuff ;;;;;;;;;;
View
39 rails-spec.el
@@ -24,14 +24,14 @@
;; 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"
+(defvar rails-spec:all-files "spec"
"All spec files/directories in project")
-(defvar rails-spec:runner "./script/spec"
- "Command, that run specs.")
-
-(defvar rails-spec:runner-options ""
- "Options to spec command.")
+(defun rails-spec:runner ()
+ "Command, that run specs."
+ (if (file-exists-p (rails-core:file "script/spec"))
+ (rails-core:file "script/spec")
+ "rspec"))
(defvar rails-spec:last-run nil
"Spec and arguments of last run.")
@@ -39,26 +39,23 @@
(defun rails-spec:run (files &optional options)
"Rerun previous spec run."
(setf rails-spec:last-run (cons files options))
- (let ((default-process-coding-system '(utf-8 . utf-8)))
- (rails-project:compile-in-root
- (concat rails-spec:runner " "
- rails-spec:runner-options " "
- options " "
- files))))
+ (rails-script:run (rails-spec:runner)
+ (list options files)
+ 'rails-test:compilation-mode))
(defun rails-spec:run-current ()
"Run spec for the current controller/model/mailer."
(interactive)
(let* ((type (rails-core:buffer-type))
(spec (cond
- ((find type '(:model :mailer :rspec-fixture))
- (rails-core:rspec-model-file (rails-core:current-model)))
- ((find type '(:controller :helper :view))
- (rails-core:rspec-controller-file (rails-core:current-controller)))
- ((find type '(:rspec-model :rspec-controller :rspec-lib))
- (buffer-file-name))
- ((eql type :lib)
- (rails-core:rspec-lib-file (rails-core:current-lib))))))
+ ((find type '(:model :mailer :rspec-fixture))
+ (rails-core:rspec-model-file (rails-core:current-model)))
+ ((find type '(:controller :helper :view))
+ (rails-core:rspec-controller-file (rails-core:current-controller)))
+ ((find type '(:rspec-model :rspec-controller :rspec-lib))
+ (buffer-file-name))
+ ((eql type :lib)
+ (rails-core:rspec-lib-file (rails-core:current-lib))))))
(if spec
(rails-spec:run spec)
(message "No spec found for %s" (buffer-file-name)))))
@@ -66,7 +63,7 @@
(defun rails-spec:run-all ()
"Run spec for all files in project (rails-spec:all-files variable)"
(interactive)
- (rails-spec:run rails-spec:all-files))
+ (rails-spec:run (rails-core:file rails-spec:all-files)))
(defun rails-spec:run-last ()
"Rerun previous spec run."
View
1  rails.el
@@ -197,6 +197,7 @@ Emacs w3m browser."
(:fixture "test/fixtures/")
(:lib "lib")
(:rspec-controller "spec/controllers")
+ (:rspec-controller "spec/requests")
(:rspec-fixture "spec/fixtures")
(:rspec-lib "spec/lib")
(:rspec-model "spec/models")
Please sign in to comment.
Something went wrong with that request. Please try again.