Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

Commit

Permalink
Can identify amrita and exunit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjoern Rochel committed Nov 5, 2013
1 parent 2c464e8 commit 4f704dd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions plugin/extest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ if !exists("extest_amrita_run_test_cmd")
let s:extest_amrita_run_test_cmd = "mix amrita '%f:%l'"
endif

" Exported commands
command ExTestRunFile call <SID>RunFile()
command ExTestRunTest call <SID>RunTest()
command ExTestRunLast call <SID>RunLast()

function s:RunFile()
echo "RunFile called."
echo s:IdentifyFramework()
endfunction

function s:RunTest()
Expand All @@ -33,3 +35,23 @@ endfunction
function s:RunLast()
echo "RunLast called."
endfunction

let s:framework_identifiers = {}
let s:framework_identifiers['^\s*test\s*"'] = "exunit"
let s:framework_identifiers['^\s*use ExUnit.Case\s*'] = "exunit"
let s:framework_identifiers['^\s*\(it\|fact\|facts\|describe\|context\|specify\) \s*'] = "amrita"
let s:framework_identifiers['^\s*use Amrita.Sweet\s*'] = "amrita"

function s:IdentifyFramework()
let l:ln = a:firstline
while ln > 0
let line = getline(l:ln)
for pattern in keys(s:framework_identifiers)
if line =~ pattern
return s:framework_identifiers[pattern]
endif
endfor
let l:ln -= 1
endwhile
return 0
endfunction

0 comments on commit 4f704dd

Please sign in to comment.