vim-rspec-quickfix


Ⅰ. 插件描述

Run your tests, get the results in VIMs amazing quickfix buffer.

Ⅱ. 基本信息

创建日期:  2013-10-26
使用用户:  1
Github星:  14
插件作者:  Mark Lorenz

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'dapplebeforedawn/vim-rspec-quickfix'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'dapplebeforedawn/vim-rspec-quickfix'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'dapplebeforedawn/vim-rspec-quickfix'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/dapplebeforedawn/vim-rspec-quickfix

Ⅳ. 文档说明

# VIM Rspec Quickfix

Get your rspec errors in VIM's quickfix

TL;DR, A Screen Shot

vim-rspec-quickfix

Installation

This repo is more of a how-to, than packaged sofware. Imma show you how to do it, but once you see how all the pieces fit togeather, you gotta adapt it how you like. Don't worry ruby, VIM and rspec all play by the unix rule, "streams of text", so it's really simple!

In your shell:

# Setup the spec formatter, so VIM can read rspec's output:
cp spec/support/formatters/VIM_formatter.rb YOURREPO/spec/support/formatters/vim_formatter.rb

# Run rspec with the formatter, and put the output where VIM can get it.
# (rspec lets you specify more than one formatter, so we still get nice
# documentation/progress output too! )
rspec --require=support/formatters/VIM_formatter.rb --format VimFormatter --out quickfix.out  --format progress

# `quickfix.out` now has the VIM-friendly spec output.

In VIM:

# ( these are all VIM built-in commands )
:cg quickfix.out        # load the quickfix file (you'll need to do this everytime the specs run)
:cwindow                # open the quickfix

# In the quickfix buffer
:cn                     # Jump to the first failure
:<a-line-number> <cr>   # Jump to a specific failure

# From any buffer
:ccl                    # Close the quickfix

# BONUS POINTS:
:map <leader>s :cg quickfix.out \| cwindow    #use leader-s to reload the file and open the quickfix

Working with Guard

Yea, this works with Guard too, cause @mikegee loves guard.

In your Guardfile:

# Requires guard >= 2.0.0

rspec_quick =  ' rspec '
rspec_quick << ' --require=support/formatters/VIM_formatter.rb '
rspec_quick << ' --format VimFormatter '
rspec_quick << ' --out quickfix.out '
rspec_quick << ' --format progress '

guard :rspec, cmd: rspec_quick do
  # normal guard config stuffs
end

Konami Code:

I generally dislike extensive extra-app tooling like guard. I also dislike leaving VIM to run rspec. So, lets map the mother of all leader commands:

# Run the specs, and open the updated quickfix on `<leader>s`
:map <leader>s :call system('rspec --require=support/formatters/VIM_formatter.rb --format VimFormatter --out quickfix.out  --format progress') \| cg quickfix.out \| cwindow

# or, without the temp file:
:map <leader>s :cgete system('rspec --require=support/formatters/vim_formatter.rb --format VimFormatter') \| cwindow

添加新评论