Skip to content

Commit b9e6c74

Browse files
committed
Add Support for Teaspoon Runner
Teaspoon is a javascript test runner for rails apps which uses the asset pipeline to manage dependencies. https://github.com/modeset/teaspoon It can be run in either CLI or the Browser. Now you can run your javascript tests directly from the comfort of Vim just like Rspec, Test::Unit, or Cucumber
1 parent ed9c647 commit b9e6c74

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

doc/turbux.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ case is to use 'spec' instead of 'rspec' for older versions of RSpec.
8282
let g:turbux_command_test_unit = 'ruby' " default: ruby -Itest
8383
let g:turbux_command_cucumber = 'cucumber' " default: cucumber -rfeatures
8484
let g:turbux_command_turnip = 'rspec' " default: rspec -rturnip
85+
let g:turbux_command_teaspoon = 'teaspoon' " default: teaspoon
8586
<
8687

8788
MAPPING *turbux-mappings*

plugin/turbux.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function! s:turbux_command_setting(name, default_value)
2020
endif
2121
endfunction
2222

23+
call s:turbux_command_setting("teaspoon", "teaspoon")
2324
call s:turbux_command_setting("rspec", "rspec")
2425
call s:turbux_command_setting("test_unit", "ruby -Itest")
2526
call s:turbux_command_setting("turnip", "rspec -rturnip")
@@ -71,6 +72,8 @@ endfunction
7172
function! s:prefix_for_test(file)
7273
if a:file =~# '_spec.rb$'
7374
return g:turbux_command_rspec
75+
elseif a:file =~# '_spec.\(coffee\|js\)$'
76+
return g:turbux_command_teaspoon
7477
elseif a:file =~# '\(\<test_.*\|_test\)\.rb$'
7578
return g:turbux_command_test_unit
7679
elseif a:file =~# '.feature$'
@@ -197,6 +200,17 @@ function! s:find_test_name_in_quotes()
197200
return ""
198201
endif
199202
endfunction
203+
204+
function! s:find_test_name_with_it()
205+
let s:line_no = search('^\s*\(it\|describe\)\s*\([''"]\).*\2', 'bcnW')
206+
if s:line_no
207+
let line = getline(s:line_no)
208+
let string = matchstr(line,'^\s*\w\+\s*\([''"]\)\zs.*\ze\1')
209+
return string
210+
else
211+
return ""
212+
endif
213+
endfunction
200214
"}}}1
201215

202216
" Public functions {{{1
@@ -220,6 +234,14 @@ function! SendFocusedTestToTmux(file, line) abort
220234
endif
221235
endif
222236

237+
if s:prefix_for_test(a:file) == g:turbux_command_teaspoon
238+
let quoted_test_name = s:find_test_name_with_it()
239+
if !empty(quoted_test_name)
240+
let focus = " --filter=\"".quoted_test_name."\""
241+
endif
242+
endif
243+
244+
223245
if !empty(s:prefix_for_test(a:file))
224246
let executable = s:command_for_file(a:file).focus
225247
let g:tmux_last_focused_command = executable

0 commit comments

Comments
 (0)