Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified emacs-rails for RSpec support

Signed-off-by: Shin-ichiro OGAWA <rust.stnard@gmail.com>

Conflicts:

	rails-core.el
	rails-ui.el
	rails.el
  • Loading branch information...
commit 14802127b506810ea9cb03e6edc63ec4bd352234 1 parent b5d2ba0
@remvee remvee authored
View
11 rails-controller-layout.el
@@ -63,7 +63,8 @@
(:controller
(if action-name
(rails-controller-layout:switch-to-view controller-name action-name)
- (rails-controller-layout:switch-to :functional-test))))))
+ (if (rails-core:spec-exist-p) (rails-controller-layout:switch-to :rspec-controller)
+ (rails-controller-layout:switch-to :functional-test)))))))
(defun rails-controller-layout:create-view-for-action (controller-name action-name)
(let ((type
@@ -129,6 +130,9 @@ If the action is nil, return all views for the controller."
rails-controller-layout:switch-to-functional-test
:enable (and (not (rails-core:current-mailer))
(not (eq (rails-core:buffer-type) :functional-test)))))
+ ([goto-rspec-controller] '(menu-item "Go to RSpec"
+ rails-controller-layout:switch-to-rspec-controller
+ :enable (not (eq (rails-core:buffer-type) :rspec-controller))))
([goto-controller] '(menu-item "Go to Controller"
rails-controller-layout:switch-to-controller
:enable (and (not (rails-core:current-mailer))
@@ -143,6 +147,7 @@ If the action is nil, return all views for the controller."
((rails-key "f") 'rails-controller-layout:switch-to-functional-test)
((rails-key "c") 'rails-controller-layout:switch-to-controller)
((rails-key "u") 'rails-controller-layout:switch-to-unit-test)
+ ((rails-key "r") 'rails-controller-layout:switch-to-rspec-controller)
([menu-bar rails-controller-layout] (cons name menu))))
map))
@@ -154,6 +159,7 @@ If the action is nil, return all views for the controller."
(item (case type
(:helper (rails-core:helper-file controller))
(:functional-test (rails-core:functional-test-file controller))
+ (:rspec-controller (rails-core:rspec-controller-file controller))
(:controller (rails-core:controller-file controller))
(:model (rails-core:model-file model))
(:unit-test (rails-core:unit-test-file mailer))
@@ -169,6 +175,7 @@ If the action is nil, return all views for the controller."
(defun rails-controller-layout:switch-to-helper () (interactive) (rails-controller-layout:switch-to :helper))
(defun rails-controller-layout:switch-to-functional-test () (interactive) (rails-controller-layout:switch-to :functional-test))
+(defun rails-controller-layout:switch-to-rspec-controller () (interactive) (rails-controller-layout:switch-to :rspec-controller))
(defun rails-controller-layout:switch-to-controller () (interactive) (rails-controller-layout:switch-to :controller))
(defun rails-controller-layout:switch-to-model () (interactive) (rails-controller-layout:switch-to :model))
(defun rails-controller-layout:switch-to-migration () (interactive) (rails-controller-layout:switch-to :migration))
@@ -193,6 +200,8 @@ If the action is nil, return all views for the controller."
(add-to-list 'item (cons "Helper" :helper)))
(unless (eq type :functional-test)
(add-to-list 'item (cons "Functional Test" :functional-test)))
+ (unless (eq type :rspec-controller)
+ (add-to-list 'item (cons "RSpec" :rspec-controller)))
(unless (eq type :controller)
(add-to-list 'item (cons "Controller" :controller))))
(when mailer
View
94 rails-core.el
@@ -35,14 +35,18 @@
"app/helpers"
"test/unit"
"test/functional"
- "test/fixtures")
+ "spec/controllers"
+ "spec/fixtures"
+ "spec/lib"
+ "spec/models"
+ "lib")
"Directories with Rails classes"
:group 'rails
:type '(repeat string))
(defun rails-core:class-by-file (filename)
"Return the class associated with FILENAME.
- <rails-root>/(app/models|app/controllers|app/helpers|test/unit|test/functional)/foo/bar_baz
+ <rails-root>/(app/models|app/controllers|app/helpers|test/unit|test/functional|lib|spec/controllers|spec/lib|spec/models)/foo/bar_baz
--> Foo::BarBaz"
(let* ((case-fold-search nil)
(path (replace-regexp-in-string
@@ -315,6 +319,50 @@ CONTROLLER."
controller
(concat controller "Controller")))
+(defun rails-core:rspec-controller-file (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))))
+
+(defun rails-core:lib-file (lib-name)
+ "Return the model file from the lib name."
+ (when lib-name
+ (concat "lib/" (rails-core:file-by-class lib-name))))
+
+(defun rails-core:rspec-lib-file (lib)
+ "Return the lib spec file name for the lib named LIB."
+ (when lib
+ (format "spec/lib/%s_spec.rb" (rails-core:file-by-class lib t))))
+
+(defun rails-core:rspec-model-file (model)
+ "Return the model spec file name for the model named MODEL."
+ (when model
+ (format "spec/models/%s_spec.rb" (rails-core:file-by-class model t))))
+
+(defun rails-core:rspec-fixture-file (model)
+ "Return the rspec fixtures file name for the model named MODEL."
+ (when model
+ (format "spec/fixtures/%s.yml" (pluralize-string (rails-core:file-by-class model t)))))
+
+(defun rails-core:rspec-lib-exist-p (lib)
+ "Return the lib spec file name for the model named MODEL."
+ (let ((spec (rails-core:rspec-lib-file lib)))
+ (when spec
+ (file-exists-p (rails-core:file spec)))))
+
+(defun rails-core:rspec-model-exist-p (model)
+ "Return the model spec file name for the model named MODEL."
+ (let ((spec (rails-core:rspec-model-file model)))
+ (when spec
+ (file-exists-p (rails-core:file spec)))))
+
+(defun rails-core:rspec-fixture-exist-p (model)
+ (when model
+ (file-exists-p
+ (rails-core:file (rails-core:rspec-fixture-file model)))))
+
;;;;;;;;;; Functions that return collection of Rails objects ;;;;;;;;;;
(defun rails-core:observer-p (name)
(when name
@@ -485,6 +533,29 @@ If the action is nil, return all views for the controller."
"Return the parent classes of controllers."
(rails-core:extract-ancestors (rails-core:controllers)))
+(defun rails-core:rspec-controllers ()
+ "Return a list of Rails controller specs."
+ (mapcar
+ #'(lambda(it)
+ (remove-postfix (rails-core:class-by-file it)
+ "Spec"))
+ (find-recursive-files "\\.rb$" (rails-core:file "spec/controllers/"))))
+
+(defun rails-core:rspec-models ()
+ "Return a list of Rails model specs."
+ (mapcar
+ #'(lambda(it)
+ (remove-postfix (rails-core:class-by-file it)
+ "Spec"))
+ (find-recursive-files "\\.rb$" (rails-core:file "spec/models/"))))
+
+(defun rails-core:rspec-fixtures ()
+ "Return a list of Rails RSpec fixtures."
+ (mapcar
+ #'(lambda (l)
+ (replace-regexp-in-string "\\.[^.]+$" "" l))
+ (find-recursive-files "\\.yml$" (rails-core:file "spec/fixtures/"))))
+
;;;;;;;;;; Getting Controllers/Model/Action from current buffer ;;;;;;;;;;
(defun rails-core:current-controller ()
@@ -496,7 +567,8 @@ If the action is nil, return all views for the controller."
(:view (rails-core:class-by-file
(directory-file-name (directory-of-file (buffer-file-name)))))
(:helper (remove-postfix file-class "Helper"))
- (:functional-test (remove-postfix file-class "ControllerTest"))))))
+ (:functional-test (remove-postfix file-class "ControllerTest"))
+ (:rspec-controller (remove-postfix file-class "Spec"))))))
(defun rails-core:current-model ()
"Return the current Rails model."
@@ -506,7 +578,17 @@ If the action is nil, return all views for the controller."
(:migration (rails-core:model-by-migration-filename (buffer-name)))
(:model file-class)
(:unit-test (remove-postfix file-class "Test"))
- (:fixture (singularize-string file-class))))))
+ (:fixture (singularize-string file-class))
+ (:rspec-fixture (singularize-string file-class))
+ (:rspec-model (remove-postfix file-class "Spec"))))))
+
+(defun rails-core:current-lib ()
+ "Return the current lib."
+ (let* ((file-class (rails-core:class-by-file (buffer-file-name))))
+ (unless (rails-core:mailer-p file-class)
+ (case (rails-core:buffer-type)
+ (:lib file-class)
+ (:rspec-lib (remove-postfix file-class "Spec"))))))
(defun rails-core:current-mailer ()
"Return the current Rails Mailer, else return nil."
@@ -687,4 +769,8 @@ the Rails minor mode log."
"Return non nil if the current buffer is rhtml file."
(string-match "\\.rhtml\\|\\.html\\.erb$" (buffer-file-name)))
+(defun rails-core:spec-exist-p ()
+ "Return non nil if spec directory is exist."
+ (file-exists-p (rails-core:file "spec")))
+
(provide 'rails-core)
View
1  rails-find.el
@@ -55,6 +55,7 @@
(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/views/")
(rails-find:gen "spec-helpers" "spec/helpers/")
(rails-find:gen "spec-fixtures" "spec/fixtures/")
View
61 rails-lib-layout.el
@@ -0,0 +1,61 @@
+(defun rails-lib-layout:keymap (type)
+ (let* ((name (capitalize (substring (symbol-name type) 1)))
+ (map (make-sparse-keymap))
+ (menu (make-sparse-keymap)))
+ (when type
+ (define-keys menu
+ ([goto-lib] '(menu-item "Go to Lib"
+ rails-lib-layout:switch-to-lib
+ :enable (and (not (eq (rails-core:buffer-type) :lib))
+ (rails-core:lib-exist-p (rails-core:current-lib)))))
+ ([goto-rspec] '(menu-item "Go to RSpec"
+ rails-lib-layout:switch-to-rspec-lib
+ :enable (and (not (eq (rails-core:buffer-type) :rspec-lib))
+ (rails-core:rspec-lib-exist-p (rails-core:current-lib))))))
+ (define-keys map
+ ((rails-key "l") 'rails-lib-layout:switch-to-lib)
+ ((rails-key "r") 'rails-lib-layout:switch-to-unit-test)
+ ([menu-bar rails-lib-layout] (cons name menu))))
+ map))
+
+(defun rails-lib-layout:switch-to (type)
+ (let* ((name (capitalize (substring (symbol-name type) 1)))
+ (lib (rails-core:current-lib))
+ (item (if lib lib))
+ (item (case type
+ (:rspec-lib (rails-core:rspec-lib-file item))
+ (:lib (rails-core:lib-file lib)))))
+ (if item
+ (let ((file (rails-core:file item)))
+ (if (file-exists-p file)
+ (progn
+ (find-file file)
+ (message (format "%s: %s" (substring (symbol-name type) 1) item)))
+ (message "File %s not exists" file)))
+ (message "%s not found" name))))
+
+(defun rails-lib-layout:switch-to-rspec-lib () (interactive) (rails-lib-layout:switch-to :rspec-lib))
+(defun rails-lib-layout:switch-to-lib () (interactive) (rails-lib-layout:switch-to :lib))
+
+(defun rails-lib-layout:menu ()
+ (interactive)
+ (let* ((item (list))
+ (type (rails-core:buffer-type))
+ (title (capitalize (substring (symbol-name type) 1)))
+ (lib (rails-core:current-lib)))
+ (when lib
+ (unless (eq type :rspec-lib)
+ (add-to-list 'item (cons "RSpec" :rspec-lib)))
+ (unless (eq type :lib)
+ (add-to-list 'item (cons "Lib" :lib))))
+ (when item
+ (setq item
+ (rails-core:menu
+ (list (concat title " " lib)
+ (cons "Please select.."
+ item))))
+ (typecase item
+ (symbol (rails-lib-layout:switch-to item))
+ (string (rails-core:find-file-if-exist item))))))
+
+(provide 'rails-lib-layout)
View
8 rails-lib-minor-mode.el
@@ -0,0 +1,8 @@
+(define-minor-mode rails-lib-minor-mode
+ "Minor mode for RubyOnRails libs."
+ :lighter " Lib"
+ :keymap (rails-model-layout:keymap :lib)
+ (setq rails-primary-switch-func 'rails-lib-layout:switch-to-rspec-lib)
+ (setq rails-secondary-switch-func 'rails-lib-layout:menu))
+
+(provide 'rails-lib-minor-mode)
View
19 rails-model-layout.el
@@ -41,6 +41,11 @@
:enable (and (not (eq (rails-core:buffer-type) :unit-test))
(rails-core:unit-test-exist-p (or (rails-core:current-model)
(rails-core:current-mailer))))))
+ ([goto-rspec] '(menu-item "Go to RSpec"
+ rails-model-layout:switch-to-rspec-model
+ :enable (and (not (eq (rails-core:buffer-type) :rspec-model))
+ (rails-core:rspec-model-exist-p (or (rails-core:current-model)
+ (rails-core:current-mailer))))))
([goto-migration] '(menu-item "Go to Migration"
rails-model-layout:switch-to-migration
:enable (and (not (eq (rails-core:buffer-type) :migration))
@@ -52,15 +57,21 @@
rails-model-layout:switch-to-fixture
:enable (and (not (eq (rails-core:buffer-type) :fixture))
(rails-core:fixture-exist-p (rails-core:current-model)))))
+ ([goto-rspec-fixture] '(menu-item "Go to RSpec Fixture"
+ rails-model-layout:switch-to-rspec-fixture
+ :enable (and (not (eq (rails-core:buffer-type) :rspec-fixture))
+ (rails-core:rspec-fixture-exist-p (rails-core:current-model)))))
([goto-mailer] '(menu-item "Go to Mailer"
rails-model-layout:switch-to-mailer
:enable (rails-core:mailer-exist-p (rails-core:current-mailer)))))
(define-keys map
((rails-key "m") 'rails-model-layout:switch-to-model)
((rails-key "u") 'rails-model-layout:switch-to-unit-test)
+ ((rails-key "r") 'rails-model-layout:switch-to-rspec-model)
((rails-key "g") 'rails-model-layout:switch-to-migration)
((rails-key "c") 'rails-model-layout:switch-to-controller)
((rails-key "x") 'rails-model-layout:switch-to-fixture)
+ ((rails-key "z") 'rails-model-layout:switch-to-rspec-fixture)
((rails-key "n") 'rails-model-layout:switch-to-mailer)
([menu-bar rails-model-layout] (cons name menu))))
map))
@@ -75,7 +86,9 @@
(:mailer (rails-core:mailer-file mailer))
(:controller (rails-core:controller-file-by-model model))
(:fixture (rails-core:fixture-file model))
+ (:rspec-fixture (rails-core:rspec-fixture-file model))
(:unit-test (rails-core:unit-test-file item))
+ (:rspec-model (rails-core:rspec-model-file item))
(:model (rails-core:model-file model))
(:migration (rails-core:migration-file-by-model model)))))
(if item
@@ -90,7 +103,9 @@
(defun rails-model-layout:switch-to-mailer () (interactive) (rails-model-layout:switch-to :mailer))
(defun rails-model-layout:switch-to-controller () (interactive) (rails-model-layout:switch-to :controller))
(defun rails-model-layout:switch-to-fixture () (interactive) (rails-model-layout:switch-to :fixture))
+(defun rails-model-layout:switch-to-rspec-fixture () (interactive) (rails-model-layout:switch-to :rspec-fixture))
(defun rails-model-layout:switch-to-unit-test () (interactive) (rails-model-layout:switch-to :unit-test))
+(defun rails-model-layout:switch-to-rspec-model () (interactive) (rails-model-layout:switch-to :rspec-model))
(defun rails-model-layout:switch-to-model () (interactive) (rails-model-layout:switch-to :model))
(defun rails-model-layout:switch-to-migration () (interactive) (rails-model-layout:switch-to :migration))
@@ -108,10 +123,14 @@
(add-to-list 'item (cons "Migration" :migration)))
(unless (eq type :fixture)
(add-to-list 'item (cons "Fixture" :fixture)))
+ (unless (eq type :rspec-fixture)
+ (add-to-list 'item (cons "RSpec Fixture" :rspec-fixture)))
(when (rails-core:controller-exist-p controller)
(add-to-list 'item (cons "Controller" :controller)))
(unless (eq type :unit-test)
(add-to-list 'item (cons "Unit Test" :unit-test)))
+ (unless (eq type :rspec-model)
+ (add-to-list 'item (cons "RSpec" :rspec-model)))
(unless (eq type :model)
(add-to-list 'item (cons "Model" :model))))
(when mailer
View
3  rails-model-minor-mode.el
@@ -30,7 +30,8 @@
"Minor mode for RubyOnRails models."
:lighter " Model"
:keymap (rails-model-layout:keymap :model)
- (setq rails-primary-switch-func 'rails-model-layout:switch-to-unit-test)
+ (if (rails-core:spec-exist-p) (setq rails-primary-switch-func 'rails-model-layout:switch-to-rspec-model)
+ (setq rails-primary-switch-func 'rails-model-layout:switch-to-unit-test))
(setq rails-secondary-switch-func 'rails-model-layout:menu))
(provide 'rails-model-minor-mode)
View
40 rails-navigation.el
@@ -136,6 +136,46 @@
(lambda (plugin)
(concat "vendor/plugins/" plugin "/init.rb"))))
+(defun rails-nav:goto-rspec-controllers ()
+ "Go to controller specs."
+ (interactive)
+ (rails-nav:goto-file-with-menu-from-list
+ (rails-core:rspec-controllers)
+ "Go to controller spec."
+ 'rails-core:rspec-controller-file))
+
+(defun rails-nav:goto-rspec-lib ()
+ "Go to lib specs."
+ (interactive)
+ (rails-nav:goto-file-with-menu-from-list
+ (rails-core:rspec-lib)
+ "Go to lib spec."
+ 'rails-core:rspec-lib-file))
+
+(defun rails-nav:goto-rspec-models ()
+ "Go to model specs."
+ (interactive)
+ (rails-nav:goto-file-with-menu-from-list
+ (rails-core:rspec-models)
+ "Go to model spec."
+ 'rails-core:rspec-model-file))
+
+(defun rails-nav:goto-rspec-views ()
+ "Go to view specs."
+ (interactive)
+ (rails-nav:goto-file-with-menu-from-list
+ (rails-core:rspec-views)
+ "Go to view spec."
+ 'rails-core:rspec-view-file))
+
+(defun rails-nav:goto-rspec-fixtures ()
+ "Go to rspec fuxtures."
+ (interactive)
+ (rails-nav:goto-file-with-menu-from-list
+ (rails-core:rspec-fixtures)
+ "Go to rspec fixtures."
+ 'rails-core:rspec-fixture-file))
+
(defun rails-nav:create-new-layout (&optional name)
"Create a new layout."
(let ((name (or name (read-string "Layout name? "))))
View
11 rails-rspec-controller-minor-mode.el
@@ -0,0 +1,11 @@
+(define-minor-mode rails-rspec-controller-minor-mode
+ "Minor mode for RubyOnRails controller rspec."
+ :lighter " ControllerRSpec"
+ :keymap (let ((map (rails-controller-layout:keymap :rspec-controllers)))
+ (define-key map rails-minor-mode-test-current-method-key 'rails-rspec:run-current-method)
+ (define-key map [menu-bar rails-controller-layout run] '("RSPec current method" . rails-rspec:run-current-method))
+ map)
+ (setq rails-primary-switch-func 'rails-controller-layout:switch-to-controller)
+ (setq rails-secondary-switch-func 'rails-controller-layout:menu))
+
+(provide 'rails-rspec-controller-minor-mode)
View
8 rails-rspec-fixture-minor-mode.el
@@ -0,0 +1,8 @@
+(define-minor-mode rails-rspec-fixture-minor-mode
+ "Minor mode for RubyOnRails rspec fixtures."
+ :lighter " RSpecFixture"
+ :keymap (rails-model-layout:keymap :rspec-fixture)
+ (setq rails-primary-switch-func 'rails-model-layout:switch-to-rspec-model)
+ (setq rails-secondary-switch-func 'rails-model-layout:menu))
+
+(provide 'rails-rspec-fixture-minor-mode)
View
11 rails-rspec-lib-minor-mode.el
@@ -0,0 +1,11 @@
+(define-minor-mode rails-rspec-lib-minor-mode
+ "Minor mode for RubyOnRails lib rspec."
+ :lighter " LibRSpec"
+ :keymap (let ((map (rails-lib-layout:keymap :rspec-lib)))
+ (define-key map rails-minor-mode-test-current-method-key 'rails-rspec:run-current-method)
+ (define-key map [menu-bar rails-lib-layout run] '("RSPec current method" . rails-rspec:run-current-method))
+ map)
+ (setq rails-primary-switch-func 'rails-lib-layout:switch-to-lib)
+ (setq rails-secondary-switch-func 'rails-lib-layout:menu))
+
+(provide 'rails-rspec-lib-minor-mode)
View
15 rails-rspec-minor-mode.el
@@ -0,0 +1,15 @@
+(define-minor-mode rails-rspec-minor-mode
+ "Minor mode for RubyOnRails RSpec."
+ :lighter " RSpec"
+ :keymap (let ((map (rails-model-layout:keymap :rspec)))
+ ; (define-key map rails-minor-mode-test-current-method-key 'rails-test:run-current-method)
+ ; (define-key map [menu-bar rails-model-layout run] '("Test current method" . rails-test:run-current-method))
+ map)
+ (setq rails-primary-switch-func (lambda()
+ (interactive)
+ (if (rails-core:mailer-p (rails-core:current-model))
+ (rails-model-layout:switch-to-mailer)
+ (rails-model-layout:switch-to-model))))
+ (setq rails-secondary-switch-func 'rails-model-layout:menu))
+
+(provide 'rails-rspec-minor-mode)
View
15 rails-rspec-model-minor-mode.el
@@ -0,0 +1,15 @@
+(define-minor-mode rails-rspec-model-minor-mode
+ "Minor mode for RubyOnRails models rspec."
+ :lighter " ModelRSpec"
+ :keymap (let ((map (rails-model-layout:keymap :rspec-model)))
+ (define-key map rails-minor-mode-test-current-method-key 'rails-rspec:run-current-method)
+ (define-key map [menu-bar rails-model-layout run] '("RSpec current method" . rails-rspec:run-current-method))
+ map)
+ (setq rails-primary-switch-func (lambda()
+ (interactive)
+ (if (rails-core:mailer-p (rails-core:current-model))
+ (rails-model-layout:switch-to-mailer)
+ (rails-model-layout:switch-to-model))))
+ (setq rails-secondary-switch-func 'rails-model-layout:menu))
+
+(provide 'rails-rspec-model-minor-mode)
View
6 rails-speedbar-feature.el
@@ -10,6 +10,12 @@
("Functional Tests" rails-core:functional-tests rails-core:functional-test-file)
("Unit Tests" rails-core:unit-tests rails-core:unit-test-file)
("Fixtures" rails-core:fixtures rails-core:fixture-file)
+ ("RSpec Controllers" rails-core:rspec-controllers rails-core:rspec-controller-file)
+ ("RSpec Fixtures" rails-core:rspec-fixtures rails-core:rspec-fixture-file)
+ ("RSpec Lib" rails-core:rspec-lib rails-core:rspec-lib-file)
+ ("RSpec Models" rails-core:rspec-models rails-core:rspec-model-file)
+ ("RSpec Views" rails-core:rspec-views rails-core:rspec-view-file)
+ ("Fixtures" rails-core:fixtures rails-core:fixture-file)
("Configuration" rails-core:configuration-files rails-core:configuration-file)))
(defvar rails-speedbar:menu-items nil)
View
27 rails-ui.el
@@ -80,7 +80,11 @@
([goto-unit-tests] '("Go to Unit Tests" . rails-nav:goto-unit-tests))
([goto-func-tests] '("Go to Functional Tests" . rails-nav:goto-functional-tests))
([goto-models] '("Go to Models" . rails-nav:goto-models))
- ([goto-controllers] '("Go to Controllers" . rails-nav:goto-controllers)))
+ ([goto-controllers] '("Go to Controllers" . rails-nav:goto-controllers))
+ ([goto-rspec-controllers] '("Go to RSpec Controllers" . rails-nav:goto-rspec-controllers))
+ ([goto-rspec-lib] '("Go to RSpec Lib" . rails-nav:goto-rspec-lib))
+ ([goto-rspec-models] '("Go to RSpec Models" . rails-nav:goto-rspec-models))
+ ([goto-rspec-fixtures] '("Go to RSpec Fixtures" . rails-nav:goto-rspec-fixtures)))
map))
(defconst rails-minor-mode-tests-menu-bar-map
@@ -232,6 +236,10 @@
((rails-key "\C-c g x") 'rails-nav:goto-fixtures)
((rails-key "\C-c g f") 'rails-nav:goto-functional-tests)
((rails-key "\C-c g u") 'rails-nav:goto-unit-tests)
+ ((rails-key "\C-c g r c") 'rails-nav:goto-rspec-controllers)
+ ((rails-key "\C-c g r f") 'rails-nav:goto-rspec-fixtures)
+ ((rails-key "\C-c g r l") 'rails-nav:goto-rspec-lib)
+ ((rails-key "\C-c g r m") 'rails-nav:goto-rspec-models)
;; Switch
((kbd "<M-S-up>") 'rails-lib:run-primary-switch)
@@ -282,18 +290,23 @@
((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)
((rails-key "\C-c .") 'rails-test:run-current)
((rails-key "\C-c /") 'rails-test:rerun-single)
- ((rails-key "\C-c y i") 'rails-test:run-integration)
- ((rails-key "\C-c y u") 'rails-test:run-units)
- ((rails-key "\C-c y f") 'rails-test:run-functionals)
+ ((rails-key "\C-c y i") 'rails-test:run-integration)
+ ((rails-key "\C-c y u") 'rails-test:run-units)
+ ((rails-key "\C-c y f") 'rails-test:run-functionals)
((rails-key "\C-c #") 'rails-test:run-recent)
- ((rails-key "\C-c y a") 'rails-test:run-all)
+ ((rails-key "\C-c y a") 'rails-test:run-all)
+
+ ;; RSpec
+ ((rails-key "\C-c z f") 'rails-spec:run-files)
+ ((rails-key "\C-c z .") 'rails-spec:run-this-file)
+ ((rails-key "\C-c z a") 'rails-spec:run-all)
+ ((rails-key "\C-c z l") 'rails-spec:run-last)
+ ((rails-key "\C-c z s") 'rails-spec:run-this-spec)
;; Log files
((rails-key "\C-c l") 'rails-log:open)
View
10 rails.el
@@ -77,6 +77,7 @@
(require 'rails-model-layout)
(require 'rails-controller-layout)
(require 'rails-features)
+(require 'rails-lib-layout)
(require 'rails-spec)
(require 'rails-shoulda)
@@ -191,6 +192,11 @@ Emacs w3m browser."
(:unit-test "test/unit/")
(:functional-test "test/functional/")
(:fixture "test/fixtures/")
+ (:lib "lib")
+ (:rspec-controller "spec/controllers")
+ (:rspec-fixture "spec/fixtures")
+ (:rspec-lib "spec/lib")
+ (:rspec-model "spec/models")
(:migration "db/migrate"))
"Rails file types -- rails directories map")
@@ -512,8 +518,8 @@ necessary."
(setq auto-mode-alist (cons '("\\.rxml$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.builder$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.rjs$" . ruby-mode) auto-mode-alist))
-(setq auto-mode-alist (cons '("\\.rhtml$" . html-mode) auto-mode-alist))
-(setq auto-mode-alist (cons '("\\.erb$" . html-mode) auto-mode-alist))
+(setq auto-mode-alist (cons '("\\.rhtml$" . rhtml-mode) auto-mode-alist))
+(setq auto-mode-alist (cons '("\\.erb$" . rhtml-mode) auto-mode-alist))
(modify-coding-system-alist 'file "\\.rb$" 'utf-8)
(modify-coding-system-alist 'file "\\.rake$" 'utf-8)
Please sign in to comment.
Something went wrong with that request. Please try again.