Run specs directly from vim #54

Closed
wants to merge 5 commits into
from

Projects

None yet

2 participants

@croaky
Member
croaky commented Oct 9, 2012
  • Run current spec file.
  • Run spec nearest cursor.
  • Run last spec that was run.
@croaky
Member
croaky commented Oct 9, 2012

Video of these commands on a file/spec that is running Guard/Spork in the background: http://www.screenr.com/rQi8

@croaky
Member
croaky commented Oct 9, 2012

Video of the faster feedback loops using Zeus: http://www.screenr.com/PQi8

@jferris jferris and 1 other commented on an outdated diff Oct 9, 2012
vimrc
@@ -84,3 +84,55 @@ nnoremap <Down> :echoe "Use j"<CR>
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
+" rspec mappings
+map ,t :call RunSpecFile()<CR>
@jferris
jferris Oct 9, 2012 Member

These conflict with the built-in command , (which repeats the last character find backwards - very useful).

@croaky
croaky Oct 9, 2012 Member

Changed to <Leader> in follow-up commit, thanks.

@jferris jferris and 1 other commented on an outdated diff Oct 9, 2012
vimrc
@@ -84,3 +84,55 @@ nnoremap <Down> :echoe "Use j"<CR>
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
+" rspec mappings
+map ,t :call RunSpecFile()<CR>
+map ,s :call RunNearestSpec()<CR>
+map ,l :call RunLastSpec()<CR>
+
+function! RunSpecFile()
+ if InSpecFile()
+ let t:last_spec_file_command = "zeus rspec " . @% . " -f documentation"
@jferris
jferris Oct 9, 2012 Member

Instead of communicating between these functions using global state, it might be better to rename RunSpecFile to RunCurrentSpecFile and then have it call RunSpecFile, which takes an argument (the spec file it should run).

@jferris
jferris Oct 9, 2012 Member

It also would be nice to have only one function that knows what the actual command is to run a specific file. That will make it easier for somebody to use a different format or runner (like tslime).

@croaky
croaky Oct 9, 2012 Member

Instead of communicating between these functions using global state, it might be better to rename RunSpecFile to RunCurrentSpecFile and then have it call RunSpecFile, which takes an argument (the spec file it should run).

The global state is used so RunLastSpec can work. I think we'd lose that functionality with the proposed refactoring?

@jferris
jferris Oct 9, 2012 Member

You can set that variable from RunSpecFile, so that running the latest spec (if it can't find one) will still work.

@croaky
croaky Oct 9, 2012 Member

@jferris Refactored in a525f1b

@croaky
Member
croaky commented Nov 1, 2012

I like where this is at except for the Zeus part. Maybe it could use the s alias?

@jferris
Member
jferris commented Nov 9, 2012

We could detect the rspec command based on whether or now the current directory has a zeus config.

@croaky
Member
croaky commented Nov 18, 2012

We could detect the rspec command based on whether or now the current directory has a zeus config.

@jferris Good idea. Just committed that change. Ready for re-review.

@jferris
Member
jferris commented Nov 19, 2012

Good to merge.

@jferris jferris closed this Nov 19, 2012
@croaky
Member
croaky commented Nov 19, 2012

Cool, thanks. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment