问题
I'm using Sublime Text 2 and installed the RubyTest package. I'm trying to run a test using Command-Shift-R.
I also use rbenv for ruby and have installed gems using Bundler.
The output is:
/bin/sh: rspec: command not found
The console shows the following command was run:
cd '/Users/user/Dropbox/code/app/' && rspec spec/controllers/profile_controller_spec.rb -l 163
When I run that command in Terminal, it works fine. Any why it wouldn't work in Sublime?
回答1:
How are you starting the sublime?
Following url should help you in starting sublime from terminal, which should fix this problem http://www.sublimetext.com/docs/2/osx_command_line.html
回答2:
To build upon Harun's correct answer:
- Set up subl for the command line per http://www.sublimetext.com/docs/2/osx_command_line.html
- Create a sublime project file per http://www.sublimetext.com/docs/2/projects.html (this file can be saved in any directory and called whatever you wish
- Open the project file using
subl --project name_of_your_project_file.sublime-workspace
Then when you run the tests inside sublime, it will know where to look.
回答3:
I spent many hours struggling with this same problem! I could not get rspec to run within Sublime Text 2, using the Michael Hartl "Ruby on Rails Tutorial." It kept saying
/bin/sh: rspec: command not found
I finally realized that the RubyTest package (https://github.com/maltize/sublime-text-2-ruby-tests) was looking in the WRONG PLACE for my RVM! (Since you use rbenv, I will change my answer for this.)
On my Mac, the path for RubyTest is /Library/Application Support/Sublime Text 2/Packages/Ruby Test
First, to make RubyTest seek the rbenv, I changed the parameter in RubyTest.sublime-settings from
"check_for_rbenv": false, to "check_for_rbenv": true,
Then I dug into the Python code of run_ruby_test.py: https://github.com/maltize/sublime-text-2-ruby-tests/blob/master/run_ruby_test.py
At line 129, inside class BaseRubyTask, it had the wrong path for my rbenv:
rbenv_cmd = os.path.expanduser('~/.rbenv/bin/rbenv')
I changed it to the full correct path: rbenv_cmd = os.path.expanduser('/usr/local/rvm/bin/rbenv')
If this is not your path, find the correct path by typing
"which rbenv" and substitute that instead.
After saving run_ruby_test.py, I went to Terminal, cd to my Rails application directory, and ran "spork"
Finally, I opened static_pages_spec.rb in Sublime Text 2. Now all the tests work from it!
来源:https://stackoverflow.com/questions/9006249/rubytest-with-sublimetext-2