sponsor Vim development Vim logo Vim Book Ad

Rubytest.vim : Run ruby tests in vim

 script karma  Rating 228/66, Downloaded by 3500  Comments, bugs, improvements  Vim wiki

created by
script type
Rubytest.vim will help you to run ruby test (including vanilla test, rspec, shoulda etc.) in vim.


Unzip downloaded file and copy rubytest.vim to your ~/.vim/plugin directory.


After installation, press <Leader>t will run the test under your cursor if you are editing a ruby test file.


$ cd <your rails/merb root>
$ vim test/unit/user_test.rb
(move cursor into a test case, press <Leader>t)

(<Leader> is mapping to '\' by default in vim)

Be default, the plugin will print output in terminal. You can change this behavior by putting this line in your vimrc file:

  let g:rubytest_in_quickfix = 1

With this set, test errors will be displayed in quickfix window, and you can jump to the error location quickly by select the error message and hit return (or 'Ctrl-w return' to open it in new window).

You can customize the command which will be used to run the test case by settting these options in your vimrc file:

  let g:rubytest_cmd_test = "ruby %p"
  let g:rubytest_cmd_testcase = "ruby %p -n '/%c/'"
  let g:rubytest_cmd_spec = "spec -f specdoc %p"
  let g:rubytest_cmd_example = "spec -f specdoc %p -e '%c'"
  let g:rubytest_cmd_feature = "cucumber %p"
  let g:rubytest_cmd_story = "cucumber %p -n '%c'"

(%p will be replaced by the path of test file, %c will be replaced by the name of test case under cursor)

Default Key Bindings

<Leader>t: run test case under cursor
<Leader>T: run all tests in file
<Leader>l: run the last test, from any buffer

You can change default key bindings:

  map <Leader>\ <Plug>RubyTestRun " change from <Leader>t to <Leader>\
  map <Leader>] <Plug>RubyFileRun " change from <Leader>T to <Leader>]
  map <Leader>/ <Plug>RubyTestRunLast " change from <Leader>l to <Leader>/

The latest code is hosted on http://github.com/janx/vim-rubytest/tree/master


* rubytest.vim works perfectly with vim-localvimrc, which enables you to set different test run command for different projects. Check details at: https://github.com/embear/vim-localvimrc
install details
Unzip downloaded file and copy rubytest.vim to your ~/.vim/plugin directory.

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
rubytest.tar.bz2 1.3.0 2016-01-14 7.0 jan * add new placeholder %s
* update for MiniTest
* better quickfix mode
* default to use new rspec command line
rubytest.tar.bz2 1.2.1 2013-03-21 7.0 jan * Use exact case match for minitest
* support for capybara steak-like dsl (feature/scenario)
rubytest.tar.bz2 1.2.0 2013-03-05 7.0 jan * Add Scenario Outline keyword to test cases (Ben Simpson)
* Run minitest in RSpec-like DSL (alexbel)
* Escape pound symbol in test name
* Global substitution for %c and %p in customized command (Ivan Tkalin)
rubytest.tar.bz2 1.1.0 2011-06-17 7.0 jan * Remember last run: <Leader>l to run last run test
* Default support to rspec2. You need to customize g:rubytest_cmd_spec to work with rspec 1.*
rubytest.tar.bz2 1.0.2 2010-06-08 7.0 jan fix testunit result display in quickfix; Added describe|context patterns so we can run examples under a grouping of describe or context.
rubytest.tar.bz2 1.0.1 2010-03-29 7.0 jan show full result by default
rubytest.tar.bz2 1.0.0 2010-03-11 7.0 jan There's many changes in this new release:
* Support cucumber features
* Support rspec drb mode
* fix serveral bugs
rubytest.tar.bz2 0.9.7 2009-09-19 7.0 jan fixed escape bug on windows. (bogdan)
rubytest.tar.bz2 0.9.6 2009-06-15 7.0 jan improved support for rspec
rubytest.tar.bz2 0.9.5 2009-05-13 7.0 jan add quickfix support
rubytest.tar.bz2 0.9.1 2009-04-27 7.0 jan fix test case finder
rubytest.tar.bz2 0.9.0 2009-04-19 7.0 jan Initial upload
ip used for rating:

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