LoginSignup
1
0

More than 3 years have passed since last update.

Railsプロジェクトの *_spec.rb の中で xmpfilter を使う方法

Last updated at Posted at 2020-05-14

要点

  1. rspec/autorun を読み込むことで rspec コマンドで実行したのと同じ状況にする
  2. require "rails_helper" などが失敗しないように -I spec を指定
  3. カレントディレクトリを Rails.root に固定するため --cd に .git のあるディレクトリを指定

(defun rubyxmp ()
  (interactive)
  (let ((s "xmpfilter --dev --fork --no-warnings --poetry")
        (rspec-p (string-match "_spec" (buffer-file-name)))
        (git-root (locate-dominating-file default-directory ".git"))
        xmpfilter-command-name)
    (when rspec-p
      (setq s (concat s " -r rspec/autorun -I spec"))
      (when git-root
        (setq s (concat s " --cd " git-root))))
    (setq xmpfilter-command-name s)
    (call-interactively 'xmp)))
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0