Running Rspec from Vim
Post created 2013-11-27 22:02 by Gabe Koss.
When working on Rspec tests for Ruby code it is often useful to run the tests many times.
Run all spec tests with
:!rspec. That is helpful but sometimes you want to be
a little more finite.
Run rspec on current file
Run rspec on current line
:exe "!rspec % -l " . line('.')
Run rspec tests that match current word
:exe "!rspec % -e " . expand("<cword>")
Binding with leader
These commands are pretty useful but typing them into the command line can be
laborious. For maximum efficiency add them to your
This binds the following:
\f: save and run the current spec file.
\l: save and run the current line.
\w: save and run all tests which contain the word under the currsor
map \f :w\|!rspec %<cr> map \l :w\|:exe "!rspec % -l " . line('.')<cr> map \w :w\|:exe "!rspec % -e " . expand("<cword>")<cr>
This was originally a github gistcomments powered by Disqus