I am trying to write tests using Vader plugin but unfortunately, every time I try to invoke a
Do block it doesn't see seems to work on the text provided in Given block!
# contents of myplugin.vim function! WrapLastWord(delimiter) execute "normal! Bi" . a:delimiter . "\<ESC>ea" . a:delimiter endfunction command! -nargs=0 -buffer Bold :call WrapLastWord('*')
Given ('Sample sentence'): This is a sample Do ('bold'): A sentence\<ESC> :source ../myplugin.vim\<cr> :Bold\<CR> Expect ('Asterisk wrapping around last word'): This is a sample *sentence*
I have tried some alternatives like below but none of them seems to be making any change on text provided in Given block?
And Vader raises failures like below
- Expected: This is a sample *sentence* - Got: This is a sample sentence
However, if I write the function's instructions in Vader Do block (normal mode
Bi*\<esc>ea*) it works as expected and tests passes.
- Why am I not able to run the same instructions when called from a function/ command written in another file? What am I doing wrong?
- How do I double check and make sure if Vader is able to source the file and function properly?
- Is there a better solution to testing vim plugins/scripts?
PS: Any additional help/resource/link to content on automated testing vim plugins would be highly appretiated