Error trying to run rspec Error / Error: require 'test' LoadError: cannot load such file - test

I am trying to run RSpec for Ruby on Rails. I am running Rails 5.0. I installed the stone, set the folder with some tests.

I run the following command on the console

$ rspec --init create spec/spec_helper.rb create .rspec 

I create a file called test.rb.

 class Test end 

I am creating a file called "zombie_spec.rb".

 require 'spec_helper' require 'test' describe Test do it " Name Is Bapu." do # test = test.new # test.name.should == 'bapu' end end 

Then after executing this command

 rspec spec/lib/zombie_spec.rb 

Shows an error ⬇

 An error occurred while loading ./spec/lib/zombie_spec.rb. Failure/Error: require 'test' LoadError: cannot load such file -- test # ./spec/lib/zombie_spec.rb:2:in `require' # ./spec/lib/zombie_spec.rb:2:in `<top (required)>' No examples found. Finished in 0.00026 seconds (files took 0.40148 seconds to load) 0 examples, 0 failures, 1 error occurred outside of examples 

How do I solve this problem to start running tests?

-one
ruby ruby-on-rails-5 rspec rspec-rails rspec3
Jul 31 '17 at 12:49
source share
1 answer

Your file paths are disabled, you need to have zombie_spec.rb in the spec/ folder instead of spec/lib/ or you need to move test.rb to the lib/ folder instead of being in / the project root directory.

+1
Jul 31 '17 at 15:56
source share



All Articles