thoughtbot / vim-rspec

Run Rspec specs from Vim
https://robots.thoughtbot.com
MIT License
656 stars 108 forks source link

Add support for running only failing specs #125

Closed dgmstuart closed 7 years ago

dgmstuart commented 7 years ago

Uses the --only-failures flag which was introduced in RSpec 3.3 https://relishapp.com/rspec/rspec-core/v/3-5/docs/command-line/only-failures

gylaz commented 7 years ago

I'm reluctant to add options that RSpec provides as extra functions. I think this can be customized on an individual level in .vimrc.

dgmstuart commented 7 years ago

Cool - I hadn't considered that that would be possible, but now I see that it is:

" in .vimrc:

function! RunFailingSpecs()
  let s:rspec_command = substitute(g:rspec_command, "{spec}", "--only-failures", "g")
  execute s:rspec_command
endfunction

map <Leader>f :call RunFailingSpecs()<CR>

It would have been nice to be able to define this as something like:

call RunSpecs("--only-failures")

but I guess that's not possible since that function is 'private' to the vim-rspec script? In any case it's not much duplication.

The only limitation is that this won't interact with RunLastSpec, but maybe that's actually a good thing.

Thanks for your help @gylaz