我在使用 rake 时遇到问题。我正在学习这门课程,它是 rspec 的介绍。它首先说要安装 rspec,所以我输入 gem install rspec。
ruby 1.9.3p385 (2013-02-06) [i386-mingw32]
C:\Users\Edub>gem install rspec
Successfully installed rspec-2.13.0
1 gem installed
然后我应该进入课程目录 cd learn_ruby 然后 cd 00_hello 但我的只有当我输入 cd learn_ruby-master\learn_ruby-master\00_hello
C:\Users\Edub>cd learn_ruby-master\learn_ruby-master\00_hello
然后我尝试使用 rake,就像它指示我做的那样,我得到了一些错误。我真的不知道他们是什么意思。
C:\Users\Edub\learn_ruby-master\learn_ruby-master\00_hello>rake
(in C:/Users/Edub/learn_ruby-master/learn_ruby-master)
You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use
col
our on Windows
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in
'require': cannot load such file -- hello (LoadError)
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_requir
e.rb:45:in `require'
from C:/Users/Edub/learn_ruby-master/learn_ruby-master/00_hello/hello_sp
ec.rb:116:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/cor
e/configuration.rb:819:in `load'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/cor
e/configuration.rb:819:in `block in load_spec_files'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/cor
e/configuration.rb:819:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/cor
e/configuration.rb:819:in `load_spec_files'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/cor
e/command_line.rb:22:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/cor
e/runner.rb:80:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/cor
e/runner.rb:17:in `block in autorun'
rake aborted!
C:/Ruby193/bin/ruby.exe -S rspec C:/Users/Edub/learn_ruby-master/learn_ruby-
master/00_hello/hello_spec.rb -IC:/Users/Edub/learn_ruby-master/learn_ruby-
master/00_hello -IC:/Users/Edub/learn_ruby-master/learn_ruby-
master/00_hello/solution -fdocumentation -r ./rspec_config failed
Tasks: TOP => default => spec
(See full trace by running task with --trace)
然后课程说应该发生错误,并且应该看起来像这样:
no such file to load -- test-first-teaching/hello/hello (LoadError)
好的,然后它指示我必须在标题为 hello.rb 的文本编辑器中定义一个方法,代码应如下所示:
def hello
"Hello!"
end
所以我继续按照说明在 Sublime 2 中完成所有这些工作。我在 Sublime 2 hello.rb 中为程序命名并定义方法。这应该可以修复所有错误,但我仍然遇到与一开始所做的相同的长错误。
有人可以告诉我这里发生了什么以及为什么 rake 被中止。我不知道它想在这里告诉我什么。谢谢!如果我不够具体,请告诉我。