11
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

Emacs内からrspecテストをiTerm上で走らせる設定

specを編集→行指定でrspecコマンド実行,というサイクルが多いので,Emacsからキーバインド一発で実行できるようにした.
出力結果はiTermで見たいので,Emacs内でrspecコマンドを実行するのではなくapplescriptを使ってiTermにコマンドを書き出させるようにしている.

ruby-config.el
(defun execute-rspec ()
  (interactive)
  (do-applescript (format "tell application \"iTerm\"
  activate
  tell current session of current terminal
    write text \"bundle exec rspec %s:%s\"
  end tell
  end tell
  tell application \"System Events\"
    keystroke return
  end tell"
  buffer-file-name (line-number-at-pos))))

(define-key ruby-mode-map (kbd "C-c r") 'execute-rspec)

実行するとbundle exec /path/to/some_spec.rb:10のようなコマンドがiTerm上で実行される

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
11
Help us understand the problem. What are the problem?