Skip to content
Browse files

Enables to run single unit test by its name

  • Loading branch information...
1 parent b0e55f6 commit 138d9854f42bd0438f2deac6c221c5d0f9ed0377 @avbranco avbranco committed with jgdavey Mar 3, 2012
Showing with 16 additions and 3 deletions.
  1. +3 −2 doc/turbux.txt
  2. +13 −1 plugin/turbux.vim
View
5 doc/turbux.txt
@@ -63,11 +63,12 @@ The default mapping for focused test output is <leader>T.
MAPPING *turbux-mappings*
<Plug>SendTestToTmux Normal invocation
-<Plug>SendFocusedTestToTmux Focused test (appends line number)
+<Plug>SendFocusedTestToTmux Focused test (appends line number or named
+test)
And the following are available unless "g:no_turbux_mappings" is set:
<leader>t Normal invocation
-<leader>T Focused test (appends line number)
+<leader>T Focused test
vim:tw=78:et:ft=help:norl:
View
14 plugin/turbux.vim
@@ -71,6 +71,15 @@ function! s:send_test(executable)
return Send_to_Tmux(" ".executable."\n")
endfunction
+function! s:execute_test_by_name()
+ let s:line_no = search('^\s*def\s*test_', 'bcnW')
+ if s:line_no
+ return " -n \"" . split(getline(s:line_no))[1] . "\""
+ else
+ return ""
+ endif
+endfunction
+
" Public functions
function! SendTestToTmux(file) abort
let executable = s:command_for_file(a:file)
@@ -80,8 +89,12 @@ function! SendTestToTmux(file) abort
return s:send_test(executable)
endfunction
+
function! SendFocusedTestToTmux(file, line) abort
let focus = ":".a:line
+ if s:prefix_for_test(a:file) == 'ruby -Itest '
+ let focus = s:execute_test_by_name()
+ endif
if s:prefix_for_test(a:file) != ''
let executable = s:command_for_file(a:file).focus
@@ -91,7 +104,6 @@ function! SendFocusedTestToTmux(file, line) abort
else
let executable = ''
endif
-
return s:send_test(executable)
endfunction

0 comments on commit 138d985

Please sign in to comment.
Something went wrong with that request. Please try again.