Last active
October 8, 2015 07:48
-
-
Save kizzx2/3301344 to your computer and use it in GitHub Desktop.
Vim function to run individual test function in Ruby MiniTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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