Spec runner for Vim. Run Rspec and Mocha tests straight from Vim.
Inspired by thoughtbot/vim-rspec and geekjuice/vim-mocha.
A hacked-up marriage between vim-rspec and vim-mocha. Determines whether to run
Mocha or Rspec based on the spec's filetype. Allows for the same mapping to
be used for all tests.
Example: Calling <leader>t in a Javascript file will call mocha. The
same mapping can be used in a Coffeescript file and call mocha with the
Coffeescript compiler. And of course, calling it from a Ruby file will invoke
rspec.
Only need Mocha? Take a look at vim-mocha!
Using vundle:
Bundle 'geekjuice/vim-spec'If using zsh on OS X it may be necessary to run move /etc/zshenv to /etc/zshrc.
Using pathogen
cd ~/.vim/bundle
git clone git://github.com/geekjuice/vim-spec.gitmap <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>Like thoughtbot/vim-rspec, the following variables can be overwritten for custom spec commands:
g:rspec_commandg:mocha_js_commandg:mocha_coffee_command
Examples:
let g:rspec_command = "!rspec --drb {spec}"
let g:mocha_js_command = "!mocha --recursive --no-colors {spec}"
let g:mocha_coffee_command = "!mocha -b --compilers coffee:coffee-script{spec}"
" Using test runners
let g:rspec_command = "Dispatch zeus rspec {spec}"
let g:mocha_coffee_command = "!cortado {spec}" "See geekjuice/vim-mocha-
Default spec command fallbacks to the dominant spec filetype i.e. Ruby, JS, Coffee in the current directory. Future update will look for {spec|test} directories rather than search the whole parent tree
-
Assertions with no name i.e. no attribute for
itin mocha will fail if trying to call nearest testRunNearestSpecas it depends onithaving a value
vim-spec is released under the MIT License.