sponsor Vim development Vim logo Vim Book Ad

Ruby Single Test : Runs a single Ruby test under the cursor

 script karma  Rating 0/0, Downloaded by 861  Comments, bugs, improvements  Vim wiki

created by
Doug McInnes
 
script type
utility
 
description
When a ruby test file with your cursor within a test block, hit
<leader>.
(that's <leader><period>) and that test, and only that test, will run in quickfix.
That's it!

Supports Test::Unit, Rspec and Minitest.  If run on an Rspec describe block it will run all the tests in that block (just using existing spec command-line functionality for that one).

The script is also hosted on GitHub:
http://github.com/dmcinnes/ruby_single_test
 
install details
Just drop the script in your .vim/plugins folder.

If you use Vundle install with ":BundleInstall dmcinnes/ruby_single_test"

If you're having problems using rspec, be sure the makeprg is set to your spec executable.  To test this type:
:echo &makeprg
While in an rspec file.  It should output "spec".

For more information read Vim's documentation on makeprg (:h makeprg).

The Specky! plugin adds lots of goodness that makes working with rspecs nice, like filetype detection and syntax highlighting:
http://www.vim.org/scripts/script.php?script_id=2286

To remap the command, to <leader>t for instance, add something like this to your .vimrc:
nmap <silent> <leader>t <Plug>ExecuteRubyTest

Ruby Single Test defaults to using make! (with the bang).  To disable this behavior drop this in your .vimrc:
let g:ruby_single_test_no_bang = 1
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ruby_single_test.vim 1.0.3 2013-05-10 7.0 Doug McInnes support both single and double quotes in minitest
ruby_single_test.vim 1.0.2 2013-05-08 7.0 Doug McInnes now supports Minitest
ruby_single_test.vim 1.0.1 2009-11-23 7.0 Doug McInnes Initial upload
ip used for rating: 18.119.133.96

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github