Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add your preferred key mappings to your `.vimrc` file.
```vim
" RSpec.vim mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>e :call RunExamples()<CR> " runs examples under cursor or in visual selection
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
```
Expand Down
17 changes: 12 additions & 5 deletions plugin/rspec.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ function! RunCurrentSpecFile()
endif
endfunction

" Preserved for backwards compatibility
function! RunNearestSpec()
call RunExamples()
endfunction

function! RunExamples() range
if s:InSpecFile()
let line_arg = ":" . join(range(a:firstline, a:lastline), ":")

let s:last_spec_file = s:CurrentFilePath()
let s:last_spec_file_with_line = s:last_spec_file . ":" . line(".")
let s:last_spec = s:last_spec_file_with_line
call s:RunSpecs(s:last_spec_file_with_line)
elseif exists("s:last_spec_file_with_line")
call s:RunSpecs(s:last_spec_file_with_line)
let s:last_spec_examples = s:last_spec_file . line_arg
let s:last_spec = s:last_spec_examples
call s:RunSpecs(s:last_spec_examples)
elseif exists("s:last_spec_examples")
call s:RunSpecs(s:last_spec_examples)
endif
endfunction

Expand Down