在我的Rails应用程序中,我将
Ruby从1.9.3更新到2.1.0.现在,当我重新开始测试时,我收到一个错误:
NameError: uninitialized constant MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
以下是Gemfile中的宝石:
gem 'rails' gem 'MysqL2' gem 'json' gem 'jquery-rails' gem 'kaminari' gem 'therubyracer' gem 'devise' gem 'rak' gem 'rails-translate-routes' gem 'routes' group :assets do gem 'sass-rails'," ~> 3.2.3" gem 'uglifier',' >= 1.0.3' end group :development,:test do gem 'factory_girl_rails' end group :test do gem 'shoulda' gem 'database_cleaner' gem 'capybara' end
这是堆栈跟踪:
`NameError: uninitialized constant MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL ~/.rvm/gems/ruby-2.1.0@kalender/gems/mocha-0.10.5/lib/mocha/integration/mini_test/version_230_to_262.rb:19:in `run'` ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit/testcase.rb:17:in `run' ~/.rvm/gems/ruby-2.1.0@kalender/gems/activesupport-3.2.12/lib/active_support/testing/setup_and_teardown.rb:36:in `block in run' ~/.rvm/gems/ruby-2.1.0@kalender/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:425:in `_run__4401979439353622961__setup__4295356768171603498__callbacks' ~/.rvm/gems/ruby-2.1.0@kalender/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback' ~/.rvm/gems/ruby-2.1.0@kalender/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks' ~/.rvm/gems/ruby-2.1.0@kalender/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks' ~/.rvm/gems/ruby-2.1.0@kalender/gems/activesupport-3.2.12/lib/active_support/testing/setup_and_teardown.rb:35:in `run' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:940:in `block in _run_suite' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:933:in `map' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:933:in `_run_suite' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:663:in `block in _run_suites' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:661:in `each' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:661:in `_run_suites' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:884:in `_run_anything' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1092:in `run_tests' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1079:in `block in _run' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1078:in `each' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1078:in `_run' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1066:in `run' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:27:in `run' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:780:in `run' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:372:in `block (2 levels) in autorun' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:33:in `run_once' ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:371:in `block in autorun'
解决方法
我刚刚遇到一个与此类似或相同的错误,并且能够在本地解决它.对我来说,我的痕迹始于:
/home/youruser/.rvm/gems/ruby-2.1.0/gems/mocha-0.10.5/lib/mocha/integration/mini_test/version_230_to_262.rb:19:in `run': uninitialized constant MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL (NameError)
这表明当mocha尝试引用从可能与Ruby升级一起出现的minitest版本中删除的常量时,错误实际上发生在mocha中.
对我来说,做一个捆绑更新摩卡修复了这个问题.
做了一些代码,专门找出问题得到解决的地方,我在mocha存储库的克隆副本上使用了“git pickaxe”(git log -SSUPPORTS_INFO_SIGNAL),它看起来像是this commit removed the reference to SUPPORTS_INFO_SIGNAL,所以在提交之后使用任何东西在摩卡应该没问题.
如果升级您的mocha版本无法解决问题,请仔细查看堆栈跟踪,您应该看到哪个库中依赖于SUPPORTS_INFO_SIGNAL的minitest导致错误.然后查看该依赖关系的上游,看看是否修复了这个问题.如果没有,请将您正在使用的依赖项展示为表现出此行为,并将您自己的补丁推送到上游.