RubyTest with SublimeText 2 [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 09:17:27

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

To build upon Harun's correct answer:

  1. Set up subl for the command line per http://www.sublimetext.com/docs/2/osx_command_line.html
  2. 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
  3. 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.

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!