尝试运行RSPEC时出错。(Error when trying to run RSPEC. Why?)

我无法弄清楚为什么我的RSPEC不起作用。 我用sudo gem install rspec重新安装RSPEC然后再次尝试使用特定版本号sudo gem install rspec -v 2.11.0 ( 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 / Users / Castillo / Desktop / document_spec .rb:1: <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加载'来自/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 / 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 /宝石/ rspe c-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在autorun run' from /Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in块中'

I can't figure out why my RSPEC isn't working. I reinstalled RSPEC with sudo gem install rspec and then tried again to install with a specific version number (sudo gem install rspec -v 2.11.0)

I continue to get the following error message and I cannot figure out what it means. I believe that I may or may not have version 1 also installed, not sure.

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 require' 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:inload' from /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:inmap' 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:inrun' 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 block in autorun'

最满意答案

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

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

Add full path to your document.rb file into spec file or use require_relative or

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

更多推荐