I am trying to run RSpec for Ruby on Rails. I am running Rails 5.0 I have installed the gem, have established a spec folder with some tests.
I run following command on console
$ rspec --init
create spec/spec_helper.rb
create .rspec
I create file called 'test.rb'.
class Test
end
I create 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 I run this command.
rspec spec/lib/zombie_spec.rb
It shows 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 resolve this so that I can start running tests?
Your file paths are off, you either need to have zombie_spec.rb
in the spec/
folder instead of spec/lib/
or you need to move test.rb
into the lib/
folder instead of being in the /
project root folder.