vim-spec


Ⅰ. 插件描述

Run Rspec or Mocha from Vim

Ⅱ. 基本信息

创建日期:  2013-12-09
使用用户:  31
Github星:  9
插件作者:  Nicholas Hwang

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# vim-spec

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!__

Installation

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.git

Example of key mappings

map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>

Configuration

Like thoughtbot/vim-rspec, the
following variables can be overwritten for custom spec commands:

  • g:rspec_command
  • g:mocha_js_command
  • g: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

Notes/Issues

  • 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 it in mocha will fail if
    trying to call nearest test RunNearestSpec as it depends on it having a

value

Credits

thoughtbot/vim-rspec

geekjuice/vim-mocha

License

vim-spec is released under the MIT License.

添加新评论