Permalink
Browse files

replace rails-spec:run-this-file by rails-spec:run-current

  • Loading branch information...
remvee committed Dec 2, 2009
1 parent 396a3e4 commit db1c0c0aa16e6917126bd10d734855565b716b48
Showing with 16 additions and 4 deletions.
  1. +15 −3 rails-spec.el
  2. +1 −1 rails-ui.el
View
@@ -46,10 +46,22 @@
rails-spec:runner-options " "
files))))
-(defun rails-spec:run-this-file ()
- "Run spec for current file"
+(defun rails-spec:run-current ()
+ "Run spec for the current controller/model/mailer."
(interactive)
- (rails-spec:run-files (buffer-file-name (current-buffer))))
+ (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))))))
+ (if spec
+ (rails-spec:run-files spec)
+ (message "No spec found for %s" (buffer-file-name)))))
(defun rails-spec:run-all ()
"Run spec for all files in project (rails-spec:all-files variable)"
View
@@ -305,7 +305,7 @@
;; 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 .") 'rails-spec:run-current)
((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)

0 comments on commit db1c0c0

Please sign in to comment.