0

I am really trying to learn Ruby, RoR and proper BDD and just getting my feet wet with starting to learn Rspec. I am going through the Rspec tutorial at codeschool (along with Rspec tutorial from Nettuts among a few others). Every time I try to get Rspec running I keep getting the following errors. I have googled most of the lines to see what I need to edit and have even haven't gotten even further confused!! I searched through threads, uninstalled RVM and re-installed RVM, installed the rspec gem in the project folder and as I follow the various tuts I can't get past through the first steps to see the test fail! I am going bonkers on this issue. I want to learn and wonder if anyone can give me some feedback on my idiot noob question. Yes I am a stupid noob but I want to figure this out.

rspec /home/username/Desktop/zombie/spec/lib/zombie_spec.rb
/home/mike/.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/username/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/username/Desktop/zombie/spec/lib/zombie_spec.rb:1:in `<top (required)>'
    from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
    from /home/username/.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/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
    from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
    from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
    from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
    from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
    from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
    from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
    from /home/username/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `load'
    from /home/username/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `<main>'
    from /home/username/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
    from /home/username/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'

Thanks so much. Another rookie noob just trying to make sense of Ruby and rspec.. mcsmythe

photoionized
  • 5,092
  • 20
  • 23
mcsmythe
  • 1
  • 1
  • The error message references "spec_helper", which is usually a file you create that defines shared stuff for all your project specs (such as loading the project library or little routines that simplify testing) - have you created this file? I think it is worth showing your test script so far (or the shortest version which still gives this error). – Neil Slater Jan 15 '15 at 16:22

2 Answers2

2

Try cd-ing into /home/username/Desktop/zombie and running your specs from there like this:

rspec spec/lib/zombie_spec.rb

also did you run:

rspec --init 

in that directory? Which will create the spec_helper for you.

rainkinz
  • 10,082
  • 5
  • 45
  • 73
  • Thank you so much. I initially cd'ed in /home/username/Desktop/zombie initially ran rspec init, which did create the spec_helper file. But a simple stupid mistake (not updating saves in text editor) and not having complete file path when running rspec. Thanks again for pointing that out. – mcsmythe Jan 15 '15 at 16:35
0

It looks like rspec is not able to find the spec_helper.rb file. Have you by chance seen this question? Also, please follow the ruby conventions and make sure all your specs are in the specs folder e.g. spec_helper's path should be specs/spec_helper.rb not lib/spec_helper.rb. Also have you tried using require_relative instead of require?

Community
  • 1
  • 1
Shishir Joshi
  • 337
  • 1
  • 2
  • 15