in 'require': no such file to load — spec_helper

前端 未结 5 1134
醉话见心
醉话见心 2020-12-29 03:04

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>         


        
相关标签:
5条回答
  • 2020-12-29 03:17

    This might be of some use - in the event rpsec wasn't installed properly on a Win7 environment.

    rails3 rspec issue

    0 讨论(0)
  • 2020-12-29 03:20

    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'
    
    0 讨论(0)
  • 2020-12-29 03:25

    Run the following command

    c:\rails_projects\sample_app>rails generate rspec:install
    

    This will put the spec_helper.rb file in your /spec directory

    0 讨论(0)
  • 2020-12-29 03:28

    When you execute 'rails generate rspec:install', if you see 'Could not find generator rspec:install' error message, add gem 'rspec-rails' within :developnent, :test group in your project Gemfile as shown below.

    group :development, :test do
      gem 'rspec-rails'
    end
    

    After this, execute 'bundle install' and continue with 'rails generate rspec:install'

    0 讨论(0)
  • 2020-12-29 03:29

    I had the same problem but for a different reason:

    in my spork.prefork block within my spec_helper.rb file I had this line

    Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
    

    but within one of the files that was being required above (spec/support/some_helper_file.rb) was a require 'spec_helper' call

    removing this unneeded require solved the issue

    0 讨论(0)
提交回复
热议问题