Ruby `要求';:无法加载这样的文件--hello(LoadError)

Ruby `要求';:无法加载这样的文件--hello(LoadError),ruby,rspec,gem,Ruby,Rspec,Gem,我正在尝试对hello文件中包含的hello方法运行测试: ruby hello_spec.rb 返回: /usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- hello (LoadError) from /usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/ru

我正在尝试对hello文件中包含的hello方法运行测试:

ruby hello_spec.rb 
返回:

/usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- hello (LoadError)
from /usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from hello_spec.rb:116:in `<main>'
/usr/local/ceral/ruby/2.1.2_2/lib/ruby/2.1.0/rubygems/core\u ext/kernel\u require.rb:55:在'require'中:无法加载这样的文件--hello(LoadError)
from/usr/local/ceral/ruby/2.1.2_2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in'require'
来自hello_spec.rb:116:in`'
这些文件包含在同一目录中。我已经安装了RSpec和(我相信)必要的gems。其他人似乎也有类似的问题,但没有一个解决方案对我有效

我正在运行Ruby 2.1.2 我是Ruby新手,正在努力(显然)正确配置环境。非常感谢您的帮助


注意:我没有编写任何测试代码。我只创建了hello.rb文件

hello\u规范rb中的
require'hello'
更改为
require\u relative'hello'
。默认情况下,当前目录不包括在默认ruby加载路径中

或者,将当前目录添加到ruby加载路径:

$:.unshift File.dirname(__FILE__)

希望有帮助。

尝试使用“加载”命令而不是“要求”命令?在ruby中加载“hello_spec.rb”只需要加载一次文件。在“加载”中包含ruby源文件。从REPL中?我得到了相同的东西。tr load'./hello_spec.rb'您的spec_helper.rb文件配置正确吗?仍然没有,谢谢您的尝试。