Working through Michael Hartle's tutorial and I cannot execute RSpec; terminal is presenting with the following error:
/Users/coreymkimball/Canvi/Tutorials/sample_app/spec/requests/static_pages_spec.rb:1:in `require': cannot load such file -- spec-helper (LoadError)
from /Users/coreymkimball/Canvi/Tutorials/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
It states that there has been a load error in the particular file; not sure how to go about creating a new one, or getting over this troubleshooting hurdle. Any help would be great.
You'll likely find that the file you made in your spec directory is called spec_helper, not spec-helper. Change the require at the top of your static_pages_spec.rb to reflect this.
Related
I am supposed to type "rake" in the terminal form directory 00_hello and get an error like
(cannot load such file -- test-first-teaching/hello/hello (LoadError)), but instead I keep getting this error:
(in /Users/deianp17/learn_ruby) /Users/deianp17/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- spec_helper (LoadError) from /Users/deianp17/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1295:in `block in requires=' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1295:in `each' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1295:in `requires=' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/configuration_options.rb:108:in `each' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/configuration_options.rb:108:in `process_options_into' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/configuration_options.rb:21:in `configure' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:105:in `setup' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:92:in `run' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:78:in `run' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/lib/rspec/core/runner.rb:45:in `invoke' from /Users/deianp17/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.4.2/exe/rspec:4:in `<main>'
Now, I've tried a lot of things and looked around google/stackoverflow for answers but none work..or maybe I'm doing something wrong
I'm teaching myself ruby and have worked with Testfirst.org's curriculum, so I've used rspec before, but in a different directory. Now I'm I'm working through the following guide: http://guides.railsgirls.com/testing-rspec/
...at the first "rspec spec/lib/idea_spec.rb" I get:
Amys-MacBook-Air:railsgirls alightholder$ rspec spec/lib/idea_spec.rb
/Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load': cannot load such file -- /Users/alightholder/Ruby/railsgirls_stuff/railsgirls/spec/lib/idea_spec.rb (LoadError)
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `each'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:96:in `setup'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:84:in `run'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:69:in `run'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:37:in `invoke'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/exe/rspec:4:in `<top (required)>'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/bin/rspec:19:in `load'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/bin/rspec:19:in `<main>'
This looks like a configuration error to me. I've tried inserting /lib/ folder in between my idea_spec.rb and the /spec/ directory, but that didn't seem to help. I'm pretty sure I'm in the right folder and so far none of the guides on this site have been inaccurate or incomplete, so I'm at a loss why I'm getting a load error instead of a test run.
for "rspec spec/idea_spec.rb" I get:
/Users/alightholder/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- idea (LoadError)
from /Users/alightholder/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/alightholder/Ruby/railsgirls_stuff/railsgirls/spec/idea_spec.rb:2:in `<top (required)>'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `each'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:96:in `setup'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:84:in `run'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:69:in `run'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:37:in `invoke'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/exe/rspec:4:in `<top (required)>'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/bin/rspec:19:in `load'
from /Users/alightholder/.rvm/gems/ruby-1.9.3-p125/bin/rspec:19:in `<main>'
Problem 1. idea_spec.rb (LoadError)
/Users/alightholder/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load': cannot load such file -- /Users/alightholder/Ruby/railsgirls_stuff/railsgirls/spec/lib/idea_spec.rb (LoadError)
Try executing rspec spec/idea_spec.rb, i.e., don't include lib.
It looks like you've initialized rspec in a directory called railsgirls which should produce a subdirectory called spec. Once you create your idea_spec.rb within the spec directory, the path to that file should simply be spec/idea_spec.rb as opposed to spec/lib/idea_spec.rb. I can't tell why the author of that guide has included lib. Also, be sure to execute rspec spec/idea_spec.rb from your railsgirls directory.
Problem 2. idea (LoadError)
/Users/alightholder/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- idea (LoadError)
Within idea_spec.rb, try changing
require "idea"
to
require "/Users/alightholder/Ruby/railsgirls_stuff/railsgirls/idea"
I'm assuming that your idea.rb is within your railsgirls directory -- if that's not right, replace the absolute path I used with the correct absolute path to your idea.rb.
After that, if you can run rspec without receiving a LoadError, then change from
require "/Users/alightholder/Ruby/railsgirls_stuff/railsgirls/idea"
(i.e., giving require an absolute path) to simply
require_relative "../idea"
I have searched for my problem and could not find it on stackoverflow. Found similar problems but none exactly like mine.
I am following Hartl's ruby on rails tutorial, however when i try to use rspec like he does i encounter this problem :
harrisspec $ rspec spec/
/home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load': cannot load such file -- /home/harris/rails_projects/myapp/spec/spec (LoadError)
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `each'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:22:in `run'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:80:in `run'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:17:in `block in autorun'
Tried running it in the root of the application folder as well (another thread said this would work) but no dice :
harris~ $ rspec spec/
/home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load': cannot load such file -- /home/harris/spec (LoadError)
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `each'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:22:in `run'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:80:in `run'
from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:17:in `block in autorun'
How do I solve this ? I don't feel comfortable continuing with the tutorial without this as I am not sure how important this is for the development of an application.
Thanks in advance!!
The exception thrown from your second attempt suggests you ran it from your home directory, not the root application directory. Since (presumably) no rspec directory exists there, the LoadError makes sense. Going by the error in your first attempt, the correct directory would be /home/harris/rails_projects/myapp.
cd /home/harris/rails_projects/myapp
rspec spec/
Try that.
I get the following error when I am trying to set this up. I can't figure out what's going on. I'm following Michael Hartl's Rail's tutorial trying to set up for first tests and nothing seems to be working.
C:\rails_projects\sample_app>bundle exec autotest
loading autotest/rspec2
C:/rails_projects/sample_app/.autotest:1:in `require': cannot load such file -- autotest/growl (LoadError)
from C:/rails_projects/sample_app/.autotest:1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ZenTest-4.7.0/lib/autotest.rb:315:in `load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ZenTest-4.7.0/lib/autotest.rb:315:in `block in initialize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ZenTest-4.7.0/lib/autotest.rb:314:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ZenTest-4.7.0/lib/autotest.rb:314:in `initialize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/autotest/rspec2.rb:13:in `initialize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ZenTest-4.7.0/lib/autotest.rb:244:in `new'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ZenTest-4.7.0/lib/autotest.rb:244:in `run'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ZenTest-4.7.0/bin/autotest:6:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/bin/autotest:19:in `load'
from C:/RailsInstaller/Ruby1.9.3/bin/autotest:19:in `<main>'
you, probably have a configuration for use growl on your .autotest file.
I think you may need add on your Gemfile the following line:
gem "autotest-growl"
HI all I just recently installed rvm and all that good stuff on my macbook air and I started my rails 3.1.1 app with ruby 1.9.3. In my gem file I put down guard and rspec, now when I try and run rspec by itself or with guard I get errors thrown at me and I'm not sure why,
the output I get when I run is such,
phantom:tasks maxmarze$ guard
Please install rb-fsevent gem for Mac OSX FSEvents support
Using polling (Please help us to support your system better than that).
Please install growl_notify or growl gem for Mac OS X notification support and add it to your Gemfile
Guard is now watching at '/Users/maxmarze/rails_projects/tasks'
Guard::RSpec is running, with RSpec 2!
Running all specs
/Users/maxmarze/rails_projects/tasks/spec/requests/tasks_spec.rb:1:in `require': cannot load such file -- spec_helper (LoadError)
from /Users/maxmarze/rails_projects/tasks/spec/requests/tasks_spec.rb:1:in `<top (required)>'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'
Guard::RSpec is running, with RSpec 2!
Running all specs
/Users/maxmarze/rails_projects/tasks/spec/requests/tasks_spec.rb:1:in `require': cannot load such file -- spec_helper (LoadError)
from /Users/maxmarze/rails_projects/tasks/spec/requests/tasks_spec.rb:1:in `<top (required)>'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'
and when I run it just with normal rspec commands or using bundle's bundle exec rspec spec/requests/tasks_spec.rb I get this output,
/Users/maxmarze/rails_projects/tasks/spec/requests/tasks_spec.rb:1:in `require': cannot load such file -- spec_helper (LoadError)
from /Users/maxmarze/rails_projects/tasks/spec/requests/tasks_spec.rb:1:in `<top (required)>'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from /Users/maxmarze/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'
Needless to say I'm at a lose and have no clue why it is throwing me these errors, I've never had these problems before.
Checkout /Users/maxmarze/rails_projects/tasks/spec/spec_helper.rb, I think you forgot rails generate rspec:install