vigun


Ⅰ. 插件描述

Unclutter your test diet

Ⅱ. 基本信息

创建日期:  2016-12-15
使用用户:  2
Github星:  1
插件作者:  artem avetisyan

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'artemave/vigun'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

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

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'artemave/vigun'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'artemave/vigun'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/artemave/vigun

Ⅳ. 文档说明

# vigun
Unclutter your test diet

Build Status

What is this?

Vim plugin to run tests in a separate tmux window.

Out of the box it works with mocha, rspec and cucumber. A lot more can be supported through custom config.

Installation

Use a plugin manager:

Plugin 'artemave/vigun'

Usage

Vigun comes with no bindings, but does add the following commands:

:VigunRunTestFile - run all tests in a current file.

:VigunRunNearestTest - run test under cursor.

:VigunRunNearesTestDebug - start debug session for test under cursor. By default, for mocha, this will use --inspect-brk and copy the debug url into OS clipboard. Open new Chrome window/tab and paste it into the address bar.

:VigunShowSpecIndex - open quickfix window to quickly navigate between the tests.

:VigunCurrentTestBefore - fold everything, except current test and all relevant setup code (e.g. before/beforeEach blocks).

:VigunMochaOnly - toggle .only for a current test/context/describe.

Example bindings

au FileType {ruby,javascript,cucumber} nnoremap <leader>t :VigunRunTestFile<cr>
au FileType {ruby,javascript,cucumber} nnoremap <leader>T :VigunRunNearestTest<cr>
au FileType javascript nnoremap <leader>D :VigunRunNearestTestDebug<cr>
au FileType javascript nnoremap <Leader>o :VigunMochaOnly<cr>
au FileType {ruby,javascript} nnoremap <leader>i :VigunShowSpecIndex<cr>

Custom test commands

The default commands are mocha for javascript, rspec for ruby and cucumber for cucumber. Those can be changed. For example if some of your tests are DOM tests, then you may want to use electron-mocha and cucumber-electron instead of mocha and cucumber. The following setting (best kept in project vimrc) will do the trick:

let g:vigun_commands = [
      \ {
      \   'pattern': 'browser/.*Spec.js$',
      \   'normal': 'electron-mocha --renderer',
      \   'debug': 'electron-mocha --interactive --no-timeouts',
      \ },
      \ {
      \   'pattern': '.feature$',
      \   'normal': 'cucumber-electron',
      \   'debug': 'cucumber-electron --electron-debug',
      \ },
      \ {
      \   'pattern': 'Spec.js$',
      \   'normal': 'mocha',
      \   'debug': 'electron-mocha --interactive --no-timeouts',
      \ },
      \]

Note that pattern is a regular expression (not glob). Also note that match order matters, so it should go from more specific to less specific.

By default lines that start with it(, describe(, context( are considered test boundaries. This can be extended:

let g:vigun_extra_keywords = ['feature', 'scenario', 'example']

Both of the above combined can be used to run a lot of different types of tests.

Running Plugin Tests

git clone https://github.com/junegunn/vader.vim.git
./run_tests

添加新评论