rubyist && emacs ユーザ向けの記事です。
rspec-mode.el を使う事で、emacs で spec ファイルを開き F10 (私の場合) キーを押すだけで、カーソルの当たっている行のテストを実行できるようになります。
インストール方法
wget https://raw.github.com/pezra/rspec-mode/master/rspec-mode.el
load-pathの通っている所におく
$ vi ~/.emacs.d/init.el ;; rspec-mode.el (require 'rspec-mode) (custom-set-variables '(rspec-use-rake-flag nil))
https://github.com/pezra/rspec-mode
使い方
spec ファイルを開いて C-c , s でカーソル行の rspec を実行
その他
- toggle back and forth between a spec and it’s target (bound to `\C-c ,t`)
- verify the spec file associated with the current buffer (bound to `\C-c ,v`)
- verify the spec defined in the current buffer if it is a spec file (bound to `\C-c ,v`)
- verify the example defined at the point of the current buffer (bound to `\C-c ,s`)
- re-run the last verification process (bound to `\C-c ,r`)
- toggle the pendingness of the example at the point (bound to `\C-c ,d`)
- disable the example at the point by making it pending
- reenable the disabled example at the point
- run all specifications for project (bound to `\C-c ,a`)
http://www.emacswiki.org/RspecMode
もっと便利に - compilation バッファを小さく
$ vi ~/.emacs.d/init.el (defun my-compilation-hook () (when (not (get-buffer-window "*compilation*")) (save-selected-window (save-excursion (let* ((w (split-window-vertically)) (h (window-height w))) (select-window w) (switch-to-buffer "*compilation*") (shrink-window (- h 10))))))) (add-hook 'compilation-mode-hook 'my-compilation-hook)
もっと便利に - F10 で行指定 spec を実行
$ vi ~/.emacs.d/init.el (global-set-key [f10] 'rspec-verify-single)
init.el まとめ
;; rspec-mode.el (require 'rspec-mode) (custom-set-variables '(rspec-use-rake-flag nil)) (global-set-key [f10] 'rspec-verify-single) (defun my-compilation-hook () (when (not (get-buffer-window "*compilation*")) (save-selected-window (save-excursion (let* ((w (split-window-vertically)) (h (window-height w))) (select-window w) (switch-to-buffer "*compilation*") (shrink-window (- h 10))))))) (add-hook 'compilation-mode-hook 'my-compilation-hook)