尝试运行RSPEC时出错。为什么?

时间:2012-07-27 19:21:22

标签: ruby rspec rspec2

我无法弄清楚为什么我的RSPEC不起作用。我重新安装了带有sudo gem install rspec的RSPEC,然后又尝试使用特定版本号(sudo gem install rspec -v 2.11.0)进行安装

我继续收到以下错误消息,我无法弄清楚它的含义。我相信我可能也可能没有安装版本1,不确定。

Castillo$ rspec document_spec.rb 
  

/Users/Castillo/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in   require': no such file to load -- document (LoadError) from /Users/Castillo/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in 需要'from /Users/Castillo/Desktop/document_spec.rb:1:in <top (required)>' from /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in load'来自   /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in block in load_spec_files' from /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in map'from   /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in load_spec_files' from /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in run'from   /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in   run' from /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in 阻止自动运行'

1 个答案:

答案 0 :(得分:4)

document.rb文件的完整路径添加到spec文件中 或使用 require_relative

require File.expand_path('../document.rb', __FILE__)