在我的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'
答案 0 :(得分:8)
我刚遇到一个与此类似或相同的错误,并且能够在本地解决它。对我来说,我有一条以下开头的痕迹:
/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中。
对我来说,做bundle update mocha
解决了问题。
执行一些代码来明确解决问题的解决方法,我在mocha存储库的克隆副本上使用了“git pickaxe”(git log -SSUPPORTS_INFO_SIGNAL
),看起来像{{3} ,所以在mocha中提交之后使用任何东西都应该没问题。
如果升级您的mocha版本无法解决问题,请仔细查看堆栈跟踪,您应该看到哪个库依赖于minitest定义了SUPPORTS_INFO_SIGNAL导致错误。然后查看该依赖关系的上游,看看是否修复了这个问题。如果没有,请将您正在使用的依赖项展现为表现出这种行为并将您自己的补丁推送到上游。