`require ': cannot load such a file - spec_helper (LoadError)

I'm creating

bundler gem --test=rspec MyGem. 

in which I get the structure of the repositor.

while i'm running rspec code i'm getting an error.

  `require': cannot load such file -- spec_helper (LoadError) 

I try to apply the required relative, but I get an error like

 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>' 
+6
source share
1 answer

You start the specs from the spec folder. This will ruin the boot path. Run the specifications from the root of your project: ~/sheetal .

 rspec spec/sheetal_spec.rb 

Rspec automatically adds the spec and lib folders to the boot path. If you are already in the spec folder, rspec is going to add spec/spec to the boot path instead.

Assuming you have the code in the lib folder, you will need to add as . , and ../lib to the boot path if you want to run your tests in the spec folder.

+21
source

Source: https://habr.com/ru/post/981589/


All Articles