Skip to content

Instantly share code, notes, and snippets.

@kizzx2
Last active October 8, 2015 07:48
Show Gist options
  • Select an option

  • Save kizzx2/3301344 to your computer and use it in GitHub Desktop.

Select an option

Save kizzx2/3301344 to your computer and use it in GitHub Desktop.
Vim function to run individual test function in Ruby MiniTest
function! Rtest()
ruby <<END
line = $curbuf.line
fn = nil
if line =~ /^\s*test\s+["']([^"']+)["']\s+do/
fn = "test_#{$1.gsub(/ /, '_')}"
elsif line =~ /^\s*def\s+(test_.+)/
fn = $1
end
if fn.nil?
puts "Not a test function"
else
cmd = %(bundle exec testdrb -I test #{VIM::evaluate %(expand("%"))} -n #{fn})
VIM::evaluate %(setreg("*", "#{cmd}"))
end
END
endfunction
nmap <leader>rr :call Rtest()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment