【发布时间】:2012-12-25 22:04:39
【问题描述】:
Alex Chaffee 的 test-first ruby 课程教授如何使用 rspec。我目前坚持第一次练习,00_hello。我按照指示创建了一个文件hello.rb,其中包含代码:
def hello
"Hello!"
end
并将其放在目录00_hello 和hello_specs.rb 中。当我从目录00_hello 在终端中键入rake 时,我收到以下错误,这与rspec 错误不同:
(in /Users/stevenjli/Documents/App Academy/learn_ruby-master)
/Users/stevenjli/Documents/App Academy/learn_ruby-master/00_hello/hello_spec.rb:116:in `require': cannot load such file -- hello (LoadError)
from /Users/stevenjli/Documents/App Academy/learn_ruby-master/00_hello/hello_spec.rb:116:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load_spec_files'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:22:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:80:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:17:in `block in autorun'
rake aborted!
/usr/local/rvm/rubies/ruby-1.9.3-p286/bin/ruby -S rspec /Users/stevenjli/Documents/App\
Academy/learn_ruby-master/00_hello/hello_spec.rb -I/Users/stevenjli/Documents/App
Academy/learn_ruby-master/00_hello -I/Users/stevenjli/Documents/App Academy/learn_ruby-master
/00_hello/solution -f documentation -r ./rspec_config failed
我猜我的设置有问题。这是我正在使用的版本。
- Mac OS 10.8.2
- Ruby 版本 1.9.3
- 耙0.9.2.2
- rspec 版本 2.12.2
【问题讨论】:
-
.默认不在 LOAD_PATH 中。