Ⅰ. 插件描述
:runner: An efficient and intelligent spec runner for RSpec and JS unit testsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'gabebw/vim-spec-runner-superman'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'gabebw/vim-spec-runner-superman'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'gabebw/vim-spec-runner-superman'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/gabebw/vim-spec-runner
Ⅳ. 文档说明
Vim-spec-runner 
An efficient and intelligent spec runner for Vim.
vim-spec-runner automatically detects the test type. It can run tests using
any external command dispatcher (like vim-dispatch). It should Just Work (TM)
for most of the workflows and configurations you use each day.
It can run RSpec files or JavaScript files (with [Teaspoon]).
Benefits
- Has commands to run a single test case, run a whole spec file, or re-run the
last spec command - If you're editing a non-spec file and you run
vim-spec-runner, it
automatically falls back to running the most recent spec - Simple to use with any external command dispatcher, including Tmux ones like
[vim-tmux-runner] or [tslime] - Automatically detects and uses preloaders ([zeus] and [spring])
- Saves the current file before running specs
Installation
With vundle:
Plugin 'gabebw/vim-spec-runner'Usage
Commands
There are three commands in the public API:
:RunCurrentSpecFileruns the entire current spec file, or if not in a spec
file, re-runs the most recent command:RunFocusedSpecruns the current line in a spec, or if not in a spec file,
re-runs the most recent command:RunMostRecentSpecre-runs the most recent command
All three commands use the g:spec_runner_dispatcher variable, which is explained
in the "Configuration" section.
Custom mappings
To create your own custom mappings, we've defined mapping placeholders ([<Plug>
maps][plug]) for each of the commands to make mapping easy.
" Use <Leader>t to run the current spec file.
map <Leader>t <Plug>RunCurrentSpecFile
" Use <Leader>u to run the current line in a spec.
map <Leader>u <Plug>RunFocusedSpec
" Use <Leader>v to explicitly run the most recent spec.
map <Leader>v <Plug>RunMostRecentSpecYou must use map when you define your mappings. Note that for Magical Vim
Reasons, even though you're typing map, it's a normal-mode mapping.
Configuration
The g:spec_runner_dispatcher variable is used by all three public commands to
run specs. By default, it echoes the command and then runs it:
" Default mapping. Echo the commmand then run it:
let g:spec_runner_dispatcher = '!echo "{command}" && {command}'{command} is a placeholder and will be replaced with the actual command to
run.
You can configure this plugin to run the spec command with your dispatcher of
choice:
" Using vim-tmux-runner:
let g:spec_runner_dispatcher = 'call VtrSendCommand("{command}")'
" Using tslime.vim:
let g:spec_runner_dispatcher = 'call Send_to_Tmux("clear\n{command}\n")'
" Using vim-dispatch
let g:spec_runner_dispatcher = 'Dispatch {command}'By default, the plugin will :write the spec file before running it. To disable
that:
let g:disable_write_on_spec_run = 1This plugin will try to automatically determine your preloader (spring or zeus).
Sometimes you need to override it, which you can do by settingg:spec_runner_preloader:
let g:spec_runner_preloader = './bin/spring'
" Or disable preloading entirely:
let g:spec_runner_preloader = ''Running the plugin's tests
bundle exec rake
If you get errors on OSX about Vimrunner, try installing MacVim then re-running the specs:
$ brew install macvim