thoughtbot / vim-rspec

Run Rspec specs from Vim
https://robots.thoughtbot.com
MIT License
656 stars 108 forks source link

Add support for alternative rspec command #131

Closed timpwbaker closed 4 years ago

timpwbaker commented 6 years ago

This commit adds support for an alternative rspec command.

The use case is when some apps are running a vanilla local rails setup, and some is using some other setup such as docker.

I found myself changing my rspec_command a lot between docker and standard, so I updated the plugin to support an alternative command.

My vimrc now looks like this:

let g:rspec_command = "!bundle exec rspec {spec}"
let g:rspec_command_0 = "!docker-compose run app bundle exec rspec {spec}"
map <Leader>t :w<CR> :call RunCurrentSpecFile()<CR>
map <Leader>s :w<CR> :call RunNearestSpec()<CR>
map <Leader>l :w<CR> :call RunLastSpec()<CR>
map <Leader>a :w<CR> :call RunAllSpecs()<CR>
map <Leader>tx :w<CR> :call RunCurrentSpecFile("0")<CR>
map <Leader>sx :w<CR> :call RunNearestSpec("0")<CR>
map <Leader>lx :w<CR> :call RunLastSpec("0")<CR>
map <Leader>ax :w<CR> :call RunAllSpecs("0")<CR>

I'm a relatively inexperienced developer, and this may not be anything close to a sensible way of approaching this problem, but it saves me time and I thought it might be interesting to others. At least an interesting disucssion.