Rspec NameError:未初始化的常量链轮::引擎

Rspec NameError:未初始化的常量链轮::引擎,rspec,ruby-on-rails-5,sprockets,rails-sprockets,Rspec,Ruby On Rails 5,Sprockets,Rails Sprockets,rails5.0(从4.2升级到5.0)ruby 2.6.4,rspec3.6 我正在将rails应用程序从rails 4.2升级到5.2。目前正在尝试升级到5.0。我正在修复弃用和测试,但当前在运行规范测试时遇到了这个错误。在这里列出一个规范以节省空间,但它们都失败了,并出现了相同的错误(如下所示) 我读过很多类似的文章,但是没有关于如何修复它的真正答案——或者我的问题 tests: ruby-2.6.4 git:(upstream ⚡ rails5) 5M jdc44@dev:~/app

rails5.0
(从4.2升级到5.0)
ruby 2.6.4
rspec3.6

我正在将rails应用程序从rails 4.2升级到5.2。目前正在尝试升级到5.0。我正在修复弃用和测试,但当前在运行规范测试时遇到了这个错误。在这里列出一个规范以节省空间,但它们都失败了,并出现了相同的错误(如下所示)

我读过很多类似的文章,但是没有关于如何修复它的真正答案——或者我的问题

tests:

ruby-2.6.4  git:(upstream ⚡ rails5) 5M
jdc44@dev:~/apps/sha_student_services$ bx rspec spec/controllers/manage/course_reports_controller_spec.rb 

DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb:81)

An error occurred while loading ./spec/controllers/manage/course_reports_controller_spec.rb.
Failure/Error: require File.expand_path("../../config/environment", __FILE__)

NameError:
  uninitialized constant Sprockets::Engines
# ./vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:17:in `block in <class:Railtie>'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:67:in `block in execute_hook'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:49:in `each'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application/bootstrap.rb:78:in `block in <module:Bootstrap>'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `instance_exec'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `run'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in `block in run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in `run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in `initialize!'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `public_send'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `method_missing'
# ./config/environment.rb:8:in `<top (required)>'
# ./spec/spec_helper.rb:8:in `require'
# ./spec/spec_helper.rb:8:in `<top (required)>'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `require'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `<top (required)>'
No examples found.


Finished in 0.00039 seconds (files took 3.49 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
在该文件中,第8行是:
require file.expand\u path(“../../config/environment”,\uuuuu file\uuuu)

我列出了
sass-rails
,因为我看到了一篇关于stackoverflow的帖子,其中提到这个问题在sass-rails中得到了解决。这些gem是最新版本,但问题仍然存在

我确实将链轮降低到
3.7.0
,这给了我一个不同的错误,但仍然涉及链轮:

ruby-2.6.4  git:(upstream ⚡ rails5) 5M
jdc44@dev:~/apps/sha_student_services$ bx rspec spec/controllers/manage/course_reports_controller_spec.rb 

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:47: warning: constant ::Fixnum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:51: warning: constant ::Bignum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:110: warning: constant ::Fixnum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:111: warning: constant ::Bignum is deprecated

DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb:81)

DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors

 (called from block in <class:Railtie> at /home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:18)

An error occurred while loading ./spec/controllers/manage/course_reports_controller_spec.rb.
Failure/Error: require File.expand_path("../../config/environment", __FILE__)

NoMethodError:
  undefined method `register_preprocessor' for nil:NilClass
# ./vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:22:in `block in <class:Railtie>'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `instance_exec'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `run'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in `block in run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in `run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in `initialize!'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `public_send'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `method_missing'
# ./config/environment.rb:8:in `<top (required)>'
# ./spec/spec_helper.rb:8:in `require'
# ./spec/spec_helper.rb:8:in `<top (required)>'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `require'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `<top (required)>'
No examples found.


Finished in 0.00053 seconds (files took 3.83 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
ruby-2.6.4 git:(上游)⚡ 栏杆5)5米
jdc44@dev:~/apps/sha_学生服务$bx rspec spec/controllers/manage/course\u reports\u controller\u spec.rb
/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:47:警告:constant::Fixnum不推荐使用
/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:51:警告:常量::Bignum已被弃用
/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:110:警告:constant::Fixnum不推荐使用
/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:111:警告:常量::Bignum不推荐使用
弃用警告:工厂已弃用。请升级到factory_bot。看见https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md 以获取进一步指示。(从require at/usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb:81调用)
弃用警告:链轮方法“register\u engine”已弃用。
请使用“注册mime类型”注册mime类型,然后
使用'register\u compressor'或'register\u transformer'。
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-处理器中链轮的所有版本
(从block-in-at/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:18调用)
加载时出错。/spec/controllers/manage/course\u reports\u controller\u spec.rb。
失败/错误:需要文件。展开\u路径(“../../config/environment”,\u文件\u)
命名错误:
nil:NilClass的未定义方法“register\u preprocessor”
#./vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:22:in'block-in'
#./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in'instance_exec'
#./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in'run'
#./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in'block in run_initializer'
#./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in'run_initializers'
#./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in'initialize!'
#./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in'public_send'
#./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in'method_missing'
#./config/environment.rb:8:in`'
#./spec/spec_helper.rb:8:in'require'
#./spec/spec\u helper.rb:8:in`'
#./spec/controllers/manage/course\u reports\u controller\u spec.rb:1:in'require'
#./spec/controllers/manage/course\u reports\u controller\u spec.rb:1:in`'
没有找到任何例子。
完成时间为0.00053秒(加载文件需要3.83秒)
0个示例,0个失败,1个错误发生在示例之外
在这个输出中,有一个指向github的url,它讨论了这种不推荐。我不知道如何将其应用到我的应用程序中来解决这个问题,或者这是否是问题所在

我希望有人能更多地了解导致链轮错误的原因以及如何修复它

我很高兴编辑这篇文章,如果需要,可以添加更多内容

谢谢你看这个

jc

# ./spec/spec_helper.rb:8:in `<top (required)>'
# ./config/environment.rb:8:in `<top (required)>'
Gemfile:
...
gem 'sprockets'
gem 'sass-rails'
...
Gemfile.lock:
...
sprockets (4.0.0) 
sprockets-rails (3.2.1)
sass-rails (6.0.0)
...
ruby-2.6.4  git:(upstream ⚡ rails5) 5M
jdc44@dev:~/apps/sha_student_services$ bx rspec spec/controllers/manage/course_reports_controller_spec.rb 

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:47: warning: constant ::Fixnum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:51: warning: constant ::Bignum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:110: warning: constant ::Fixnum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:111: warning: constant ::Bignum is deprecated

DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb:81)

DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors

 (called from block in <class:Railtie> at /home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:18)

An error occurred while loading ./spec/controllers/manage/course_reports_controller_spec.rb.
Failure/Error: require File.expand_path("../../config/environment", __FILE__)

NoMethodError:
  undefined method `register_preprocessor' for nil:NilClass
# ./vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:22:in `block in <class:Railtie>'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `instance_exec'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `run'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in `block in run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in `run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in `initialize!'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `public_send'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `method_missing'
# ./config/environment.rb:8:in `<top (required)>'
# ./spec/spec_helper.rb:8:in `require'
# ./spec/spec_helper.rb:8:in `<top (required)>'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `require'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `<top (required)>'
No examples found.


Finished in 0.00053 seconds (files took 3.83 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples