Came across this error when trying out the ruby on rails tutorial section with rspec on a windows platform using jruby 1.6:
c:\rails_projects\sample_app>bundle exec rspec spec/ org/jruby/RubyKernel.java:1038:in `require': no such file to load -- spec_helper (LoadError) from c:/rails_projects/sample_app/spec/controllers/pages_controller_spec .rb:1:in `(root)' from org/jruby/RubyKernel.java:1063:in `load' from c:/rails_projects/sample_app/spec/controllers/pages_controller_spec .rb:386:in `load_spec_files' from org/jruby/RubyArray.java:2458:in `collect' from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe c/core/configuration.rb:386:in `load_spec_files' from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe c/core/command_line.rb:18:in `run' from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe c/core/runner.rb:55:in `run_in_process' from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe c/core/runner.rb:46:in `run' from c:/jruby-1.6.0.RC2/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspe c/core/runner.rb:10:in `autorun' from org/jruby/RubyProc.java:268:in `call' from org/jruby/RubyProc.java:232:in `call'
Found the answer which appears missing from the tutorial:
c:\rails_projects\sample_app>rails generate rspec:install
After running
rails generate rspec:install
Place your *_spec.rb
files under (in your example) c:\rails_projects\sample_app\spec\model
. Then specify relative path with require_relative
require_relative '../spec_helper'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With