Ⅰ. 插件描述
A Vim plugin to run specs for the current file.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mudge/runspec-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mudge/runspec-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mudge/runspec-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mudge/runspec.vim
Ⅳ. 文档说明
runspec.vim 
A simple Vim plugin to run specs: if the current file ends in _spec.rb,_test.rb or .feature, run it; if not, guess where the associated spec file
is and run that. It also includes a function for toggling between a test file
and the associated implementation file.
The plugin will attempt to automatically discover whether you are using
RSpec,
minitest/spec or
Cucumber and use Bundler (and
binstubs) if appropriate.
Installation
I recommend using Vundle and then you can
install the plugin by simply adding the following line to your .vimrc:
Bundle 'mudge/runspec.vim'Usage
By default, the plugin will bind to <Leader>t if it is not already mapped but
you can manually map to <Plug>RunSpecRun like so:
map <Leader>r <Plug>RunSpecRunYou can override the automatic detection of the appropriate spec runner (e.g.rspec or ruby) by having an executable script/test that accepts a spec
file as an argument. Note that features will always run with cucumber.
To toggle between having a test file open and the corresponding
implementation file, you can map a keybinding to<Plug>RunSpecToggle, like so:
map <Leader>s <Plug>RunSpecToggleDependencies
In order to detect custom test runners accurately, the plugin requires that you are
using Bundler and have a valid Gemfile.lock (so that it can work withGemfiles that only specify gemspec).
If you are not using any gems (e.g. you are using only Ruby's built-in testing
libraries) then you should not be affected as the plugin will default to usingruby as your test runner.
Contributions
Thanks to William Roe for contributing the toggle
functionality.
License
Copyright © 2015-2016 Paul Mucur
Distributed under the MIT License.