Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added vim plugin

  • Loading branch information...
commit 3ffef02b894daf880a079f2cff404ea2806a5e4f 1 parent 3213903
@drewolson authored
Showing with 34 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +33 −0 ruby_focused_unit_test.vim
View
1  .gitignore
@@ -0,0 +1 @@
+*.swp
View
33 ruby_focused_unit_test.vim
@@ -0,0 +1,33 @@
+command RunFocusedRubyUnitTest :call <SID>RunFocusedRubyUnitTest()
+
+function! s:RunFocusedRubyUnitTest()
+ ruby FocusedRubyUnitTest.new.run_test
+endfunction
+
+ruby << EOF
+class FocusedRubyUnitTest
+ def run_test
+ @file_name = VIM::Buffer.current.name
+ @line_number = VIM::Buffer.current.line_number
+
+ lines = File.read(@file_name).split("\n")
+
+ method_name = nil
+
+ (@line_number + 1).downto(0) do |line_number|
+ if lines[line_number] =~ /def (test_\w+)/
+ method_name = $1
+ break
+ elsif lines[line_number] =~ /test "(\w+)"/
+ method_name = "test_" + $1.split(" ").join("_")
+ break
+ end
+ end
+
+ if method_name
+ VIM::command("!ruby #{@file_name} -n #{method_name}")
+ end
+ end
+end
+EOF
+
Please sign in to comment.
Something went wrong with that request. Please try again.