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"
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 just started learning Ruby on Rails from Hartl's "Ruby on rails 3: Learn Rails by example" (but I do have rails 4.2.5). Everything worked great until I tried to deploy to Heroku - couldn't get pass the $ git push heroku master, so I found this https://devcenter.heroku.com/articles/getting-started-with-rails4#local-workstation-setup and started over according to these instructions. Everything works perfecto, apart from `
$ rails generate controller welcome`
`/Users/liisvaljaots/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file --
bundler/setup (LoadError)
from /Users/liisvaljaots/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/commands.rb:33:in `<module:Spring>'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/liisvaljaots/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liisvaljaots/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:77:in `preload'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:143:in `serve'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:131:in `block in run'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:125:in `loop'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:125:in `run'
from /Users/liisvaljaots/myapp/vendor/bundle/gems/spring-1.6.1/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/liisvaljaots/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/liisvaljaots/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'`
I'm all Googled out on this issue, maybe someone here can help.
Also, another possibly related issue is this line in my Terminal when I open it bash: eval: line 21: syntax error: unexpected end of file
Thank you!
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.
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.
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"