You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vim-vspec is a testing framework for Vim script. It consists of:
Utilities to run tests in an isolated Vim process,
A testing framework to write tests in a format which resembles RSpec, and
Additional syntax/indent files for Vim script to write tests.
A typical test script written with vim-vspec looks like as follows:
runtimeplugin/MyGitUtilities.vim
describe 'GetGitBranchName()'
before
calldelete('tmp/test', 'rf')
callmkdir('tmp/test', 'p')
cd tmp/test
end
after
cd-end
context 'in a non-Git directory'
it 'returns "-"'
Expect GetGitBranchName('.') ==# '-'endend
context 'in a Git repository'
before
!git init && touch foo && git add foo && git commit -m'Initial commit'end
it 'returns the current branch'
Expect GetGitBranchName('.') ==# 'master'end
it 'detects detached HEAD state'!git checkout master~0
Expect GetGitBranchName('.') ==# 'master~0'endendend
Typical ways to run tests are as follows:
# Run tests in a specific file.# The current directory is injected into &rutimepath before running tests.$PATH_TO_VSPEC/bin/prove-vspec -d $PWD t/branch.vim
# Like the above, but run all tests in all files under the `t` directory.$PATH_TO_VSPEC/bin/prove-vspec -d $PWD t/
# Like the above, but you may omit `t` because it's the default target.$PATH_TO_VSPEC/bin/prove-vspec -d $PWD
prove-vspec runs a test script in an isolated Vim process, and show
a summary like the above. User-specific configurations, like ~/.vimrc and
files in ~/.vim, will never be used to avoid unintentional dependencies.
For proper testing, you have to set up environment to run tests. Suppose that
you want to test a plugin which depends on some other plugins, you have to:
Install such dependencies to somewhere, and
Specify where the dependencies are installed to run tests.