`require': 无法加载这样的文件 -- spec_helper (LoadError)
`require': cannot load such file -- spec_helper (LoadError)
我正在创作
bundler gem --test=rspec MyGem.
我正在其中获取存储库结构。
当我尝试 运行 rspec
代码时,出现以下错误:
`require': cannot load such file -- spec_helper (LoadError)
然后我尝试申请 require relative 但我仍然收到错误消息:
sheetal@ubuntu:~/sheetal/spec$ rspec sheetal_spec.rb
\/home/sheetal/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- spec_helper (LoadError)
from /home/sheetal/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/sheetal/sheetal/spec/sheetal_spec.rb:1:in `<top (required)>'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `load'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `<main>'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
您正在 运行 从 spec
文件夹中获取规范。这弄乱了加载路径。 运行 来自项目根目录的规范:~/sheetal
.
rspec spec/sheetal_spec.rb
Rspec 自动将 spec
和 lib
文件夹添加到加载路径。如果您已经在 spec
文件夹中,rspec 将改为将 spec/spec
添加到加载路径。
假设您的代码在 lib
文件夹中,如果您想要 运行,则必须将 .
和 ../lib
添加到加载路径您在 spec
文件夹中的测试。
我正在创作
bundler gem --test=rspec MyGem.
我正在其中获取存储库结构。
当我尝试 运行 rspec
代码时,出现以下错误:
`require': cannot load such file -- spec_helper (LoadError)
然后我尝试申请 require relative 但我仍然收到错误消息:
sheetal@ubuntu:~/sheetal/spec$ rspec sheetal_spec.rb
\/home/sheetal/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- spec_helper (LoadError)
from /home/sheetal/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/sheetal/sheetal/spec/sheetal_spec.rb:1:in `<top (required)>'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
from /home/sheetal/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `load'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `<main>'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
from /home/sheetal/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
您正在 运行 从 spec
文件夹中获取规范。这弄乱了加载路径。 运行 来自项目根目录的规范:~/sheetal
.
rspec spec/sheetal_spec.rb
Rspec 自动将 spec
和 lib
文件夹添加到加载路径。如果您已经在 spec
文件夹中,rspec 将改为将 spec/spec
添加到加载路径。
假设您的代码在 lib
文件夹中,如果您想要 运行,则必须将 .
和 ../lib
添加到加载路径您在 spec
文件夹中的测试。