初学者 - Rails测试不起作用

时间:2017-02-08 14:49:19

标签: ruby-on-rails

我是Rails的初学者,我在" Ruby-On-Rails"由Michael Hartl创建的教程。我达到了他开始谈论" rails test"命令,但是当我运行它时,它给了我以下错误:

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'

所以我试着寻找答案,但我没有设法找到问题所在。有人可以帮忙吗?

顺便说一下,&#34; rake test&#34;命令运行正常,但我读到它与&#34; rails test&#34;有所不同。这是我的宝石(与教程相同):

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]

提前致谢!

1 个答案:

答案 0 :(得分:1)

所以,多亏了J E Carter II,我得到了解决方案:安装路径本身不应包含任何非单字符字符。

GitHub上有一个问题:as J E Carter II commented