Run your Rails tests from vim to spin
After seeing the blog post of Vladimir Saric titled Streamlining vim with RSpec and Cucumber I add some changes to run rspec test in spin. You need to add the following in ~/.vimrc file:
" Functions to run spin from VIM
function! RailsScriptIfExists(name)
" Bundle exec
if isdirectory(".bundle") || (exists("b:rails_root") && isdirectory(b:rails_root . "/.bundle"))
return "bundle exec " . a:name
" System Binary
else
return a:name
end
endfunction
function! RunSpinPush(args)
let spec = RailsScriptIfExists("spin push")
let cmd = spec . " " . a:args . " " . @%
execute ":silent ! echo " . cmd . " && " . cmd . " &>/dev/null &" | redraw!
endfunction
map <Leader>s :call RunSpinPush("")<CR>
Now you can use CTRL + s (or the key as you configure as Leader) in the rspec file (in vim) and show the test result in the terminal you're running spin serve.
Written by Maximiliano Dello Russo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Tdd
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#