Permalink
Browse files

Adds support for detecting spec_helper for bundle exec

Closes #9
  • Loading branch information...
1 parent 08a7d21 commit 9adc3df03f64da6f2f05843bb0b173da3ff32b4f @skalnik committed Apr 14, 2012
Showing with 32 additions and 1 deletion.
  1. +26 −1 autoload/vroom.vim
  2. +6 −0 doc/vroom.txt
View
27 autoload/vroom.vim
@@ -20,6 +20,10 @@ if !exists("g:vroom_cucumber_path")
let g:vroom_cucumber_path = './script/cucumber '
endif
+if !exists("g:vroom_detect_spec_helper")
+ let g:vroom_detect_spec_helper = 0
+endif
+
" Public: Run current test file, or last test run
function vroom#RunTestFile()
call s:RunTestFile()
@@ -94,13 +98,34 @@ endfunction
" Internal: Checks for Gemfile, and sets s:bundle_exec as necessary
function s:CheckForGemfile()
- if filereadable("Gemfile")
+ if s:GemfileExists()
+ let s:bundle_exec = "bundle exec "
+ else
+ let s:bundle_exec = ""
+ endif
+endfunction
+
+" Internal: Checks for 'spec_helper' in file and Gemfile existance, and sets
+" s:bundle_execs as necessary
+function s:CheckForSpecHelper(filename)
+ if g:vroom_detect_spec_helper &&
+ \match(readfile(a:filename, '', 1)[0], 'spec_helper') != -1 &&
+ \s:GemfileExists()
let s:bundle_exec = "bundle exec "
else
let s:bundle_exec = ""
endif
endfunction
+" Internal: Check if there is a Gemfile in the current working directory
+function s:GemfileExists()
+ if filereadable("Gemfile")
+ return 1
+ else
+ return 0
+ endif
+endfunction
+
" Internal: Sets t:vroom_test_file to current file
function s:SetTestFile()
" Set the test file that tests will be run for.
View
6 doc/vroom.txt
@@ -72,6 +72,11 @@ g:vroom_cucumber_path *vroom_cucumber_path*
used for *.feature files.
Default: './script/cucumber '
+g:vroom_detect_spec_helper *vroom_detect_spec_helper*
+ Only run `bundle exec` if first line of the spec file
+ requires 'spec_helper'
+ Default: 0
+
===============================================================================
LICENSE *vroom-license*
@@ -100,6 +105,7 @@ CHANGELOG *vroom-changelog*
1.0.2 *vroom-changelog-1.0.2*
* Support configuration of cucumber runner
+ * Can skip `bundle exec` if not requiring 'spec_helper'
1.0.1 *vroom-changelog-1.0.1*
* Support for writing all files before running tests (off by default)

0 comments on commit 9adc3df

Please sign in to comment.