gpt4 book ai didi

ruby-on-rails-3 - Rails 测试错误 - NameError: TestCase::SUPPORTS_INFO_SIGNAL

转载 作者:行者123 更新时间:2023-11-28 19:46:59 26 4
gpt4 key购买 nike

在我的 Rails 应用程序中,我已将 Ruby 从 1.9.3 更新到 2.1.0。现在,当我重新启动测试时,出现错误:

NameError: uninitialized constant MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL

这是 Gemfile 中的 gem:

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 尝试引用一个常量时,错误实际上发生在 mocha 中,该常量已从 minitest 版本中删除,可能伴随您的 Ruby 升级。

对我来说,bundle update mocha 解决了这个问题。

为了找出问题具体解决的地方,我做了一些代码探索,我在 mocha 存储库的克隆副本上使用了“git pickaxe”(git log -SSUPPORTS_INFO_SIGNAL),它好像是this commit removed the reference to SUPPORTS_INFO_SIGNAL ,所以在 mocha 中提交之后使用任何东西应该没问题。

如果升级您的 mocha 版本不能解决问题,请仔细查看堆栈跟踪,您应该会看到哪个依赖于定义了 SUPPORTS_INFO_SIGNAL 的 minitest 的库导致了错误。然后查看该依赖项的上游以查看此问题是否已解决。如果不是,请 fork 您正在使用的表现出此行为的依赖项,并将您自己的补丁推送到上游。

关于ruby-on-rails-3 - Rails 测试错误 - NameError: TestCase::SUPPORTS_INFO_SIGNAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20907138/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com