← Back to Upcase

Piping vim-rspec output to separate pane?


(Geoff Harcourt) #1

@croaky, @benorenstein , et al:

Been enjoying Art of Vim!

After yesterday’s blog post on running specs from within vim, I have started looking at tslime. Any chance we can get a thoughtbot-endorsed tslime/vim-rspec setup in a blog post or screencast (or even just posted here)? I feel like being able to execute the specs in a separate pane will be a huge step forward for developers trying to wean themselves off of multiple-application (GUI editor, terminal) workflow, as being able to see the failing spec while looking at your code cuts out one more thing you have to keep in memory.


(Dan Croak) #2

Hey Geoff,

Yes, we do have a tslime/vim-rspec setup blog post in draft and intend to publish it this week. Sneak preview for you, my friend.

Install vim-rspec and tslime.vim using Vundle:

Bundle 'thoughtbot/vim-rspec'
Bundle 'jgdavey/tslime.vim'

Add the following to your .vimrc:

let g:rspec_command = 'call Send_to_Tmux("rspec {spec}\n")'

This tells vim-rspec to use Send_to_Tmux to run the selected specs.

Finally, all this wouldn’t be of much use if we couldn’t run it at the press of a key. Add these keybindings to your .vimrc:

" Rspec.vim mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>

Those are already in thoughtbot/dotfiles if you’re using them.

Bonus: you can completely customize the command that gets sent to your tmux pane. For example, to run the specs using Zeus you would use:

let g:rspec_command = 'call Send_to_Tmux("zeus rspec {spec}\n")'

(Geoff Harcourt) #3

Dan,

Awesome. I saw a bunch of forks of tslime.vim, so I you just saved me a bunch of time rooting through which one is in good shape. Giving this a try today, thanks for the super-fast feedback.


(Matt Rohrer) #4

@croaky just curious - why tslime over vimux?


(Joel Quenneville) #5

Full post has been published today: Fast testing loop in tmux with vim-rspec and tslime

@matt I used tslime over vimux due to flexibility/configurability. Vimux is more opinionated and is optimized for a specific workflow.

I simply wanted to send a command to the desired tmux pane and tslime’s Send_to_Tmux() does exactly that.


(Dan Croak) #6

Not sure why Tslime over Vimux. I don’t use either. My process is the raw rspec.vim technique described in the original article.

As a heads up, there’s another Tmux integration option discussed here:


(Yevgeniy Viktorov) #7

nice, I chosen vimux for the same reason :smile:

" vimux
let g:VimuxOrientation = "h"
let g:VimuxHeight = "41"

It also comes with the functions for simplest cases: VimuxRunCommand() or VimuxPromptCommand()

But basically I’m now using it with vroom