LoginSignup
11
13

More than 5 years have passed since last update.

Rspec + QuickRun でカーソル行のテストする

Last updated at Posted at 2013-12-05

QuickRunからrspecを呼び出す

  1. 【vim】vimprocを使ってvim-quickrunからRspecを非同期実行!
  2. Hack #176: RSpecをquickrunする (2/2)

1.のサイトのソースコードをベースにして,2. のサイトを参考にカーソル行のみrspecのテストが実行されるように以下のように修正.

let g:quickrun_config['ruby.rspec'] = {'command': 'rspec', 'cmdopt': "-l {line('.')}", 'exec': ['bundle exec %c %o %s %a']}

しかし,現在行を実行しようとしても

Run options: include {:line_numbers=>[0]}

All examples were filtered out

Finished in 0.01496 seconds
0 examples, 0 failures

Randomized with seed 32968

と出てしまう.どうやら現在行がうまく取得できていないみたい.

式展開記法の変更

quickrun 0.5.0がリリースされました
によるとquickrun 0.5.0から,式展開の記法が{}から%{}に変わった模様.

改めて,

let g:quickrun_config['ruby.rspec'] = {'command': 'rspec', 'cmdopt': "-l %{line('.')}", 'exec': ['bundle exec %c %o %s %a']}

としてみると,

Run options: include {:line_numbers=>[23]}
.

Finished in 0.59313 seconds
1 example, 0 failures

Randomized with seed 53001

カーソル行の指定ができた!

この記法変更については

quickrun-syntax-option で {} が式展開になっていたものが、%{} に変更されました。多くの人は ~/.vimrc の変更が必要になります。これは大事なところなので、ぜひ一日三回はtweetしてください。
quickrun 0.5.0がリリースされました

とのことなので,1日3回ツイートするようにします.

11
13
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
11
13