thoughtbot / vim-rspec

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

Support for both `bin/rspec` and `rspec` command? #65

Closed thewatts closed 10 years ago

thewatts commented 10 years ago

Currently in my Rails projects I use Spring for quick loading. Which, with the custom setting, let g:rspec_command, that makes it easy.

Ex: let g:rspec_command = '!bundle exec bin/rspec {spec}'

However, some of my projects don't use Rails or Spring, which - in that case I need to jump back into my .vimrc.

Is there a way to set things up so that I can have the best of both worlds?


Side note: This plugin has changed my workflow completely (for the far better) - thank you for your hard work!

gylaz commented 10 years ago

You could add ./bin to your PATH. Here's how Tim Pope suggests doing it. Then for projects that have spring wrapped rspec in their bin/ directory, it will use that. Otherwise, it'll find the next available rspec in your PATH.

thewatts commented 10 years ago

@gylaz --- thanks for the quick response! I'll git it a shot!

thewatts commented 10 years ago

hey @gylaz, just used Tim Pope's suggestion - and pulled the code directly from #52, and while it works great in terminal, when I'm in vim and run the command - it's not picking up Spring.

My direct command in my vimrc now: let g:rspec_command = '!bundle exec rspec {spec}'

Am I missing something?

jferris commented 10 years ago

If you have rspec on your PATH as a binstub, you want just rspec and not bundle exec rspec. Using bundle exec will force it to find the binary from the rspec-core gem and not from Spring.

gylaz commented 10 years ago

Going to close this. @thewatts feel free to re-open if you're still having issues.

mecampbellsoup commented 9 years ago

So to be clear, the "best of both worlds" @thewatts requested can be had by let g:rspec_command = 'rspec {spec}' and adding ./bin to one's PATH - correct?

jondkinney commented 8 years ago

@mecampbellsoup from my testing just now, that is correct. Though I'm using RVM (I'm pretty sure @tpope is not), and I needed to do this to get my bin dir in the front of my path:

  1. brew install direnv
  2. Add eval $(direnv hook $0) to the end of my ~/.zshrc file
  3. Create a .envrc file in the root of my project with the following content:

    PATH_add bin