简体   繁体   中英

Beginner - Rails test doesn't work

I am a beginner in Rails, and I work on the "Ruby-On-Rails" tutorial created by Michael Hartl. I reached the point where he start to talk about the "rails test" command, but when I ran it, it gave me the following error :

D:/Cours/3eme année/Ruby On Rails/rubyonrails_ebook/workspace/sample_app/test/controllers/static_pages_controller_test.rb:1:in `require': cannot load such file -- test_helper (LoadError)
    from D:/Cours/3eme année/Ruby On Rails/rubyonrails_ebook/workspace/sample_app/test/controllers/static_pages_controller_test.rb:1:in `<top (required)>'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `require'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `each'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:86:in `plugin_rails_init'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:80:in `block in init_plugins'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:78:in `each'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:78:in `init_plugins'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:129:in `run'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:73:in `run'
    from D:/Logiciels/Ruby/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:62:in `block in autorun'

So I try to look for an answer, but i didn't manage to find what is the problem. Can someone help please ?

Btw, the "rake test" command is running correctly, but I read that it's different from "rails test". Here are my gems (same as the tutorial) :

source 'https://rubygems.org'

gem 'rails',                   '5.0.1'
gem 'bcrypt',                  '3.1.11'
gem 'faker',                   '1.6.6'
gem 'carrierwave',             '0.11.2'
gem 'mini_magick',             '4.5.1'
gem 'fog',                     '1.38.0'
gem 'will_paginate',           '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass',          '3.3.6'
gem 'puma',                    '3.4.0'
gem 'sass-rails',              '5.0.6'
gem 'uglifier',                '3.0.0'
gem 'coffee-rails',            '4.2.1'
gem 'jquery-rails',            '4.1.1'
gem 'turbolinks',              '5.0.1'
gem 'jbuilder',                '2.4.1'

group :development, :test do
  gem 'sqlite3', '1.3.12'
  gem 'byebug',  '9.0.0', platform: :mri
end

group :development do
  gem 'web-console',           '3.1.1'
  gem 'listen',                '3.0.8'
  gem 'spring',                '1.7.2'
  gem 'spring-watcher-listen', '2.0.0'
end

group :test do
  gem 'rails-controller-testing', '0.1.1'
  gem 'minitest-reporters',       '1.1.9'
  gem 'guard',                    '2.13.0'
  gem 'guard-minitest',           '2.4.4'
end

group :production do
  gem 'pg',   '0.18.4'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Thanks in advance !

So, thanks to JE Carter II, I got the solution : the path of your installation should not include any non uni-code characters in itself.

There is an issue about it on GitHub : as JE Carter II commented

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM