Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Testing Error - NameError: TestCase::SUPPORTS_INFO_SIGNAL

In my Rails app, I've updated Ruby from 1.9.3 to 2.1.0. Now when I restart my tests I get an error:

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

Here are gems in the 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

Here's the stack trace:

`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'
like image 646
stephanfriedrich Avatar asked Jan 03 '14 15:01

stephanfriedrich


1 Answers

I just came across a bug that is similar or identical to this one and was able to resolve it locally. For me, I had a trace that begins with:

/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)

This shows that the error is actually occurring in mocha when it tries to reference a constant that has been removed from the version of minitest that likely came along with your Ruby upgrade.

For me, doing a bundle update mocha fixed the problem.

Doing a bit of code spelunking to figure out specifically where the problem was fixed, I used the "git pickaxe" (git log -SSUPPORTS_INFO_SIGNAL) on a cloned copy of the mocha repository, and it seems like this commit removed the reference to SUPPORTS_INFO_SIGNAL, so using anything after that commit in mocha should be ok.

If upgrading your version of mocha doesn't solve the problem, take a close look at the stack trace and you should see which library that depends minitest having SUPPORTS_INFO_SIGNAL defined is causing the error. Then look upstream in that dependency to see if this problem was fixed. If not, fork the dependency you're using that exhibits this behavior and push your own patch upstream.

like image 114
Justin Leitgeb Avatar answered Nov 16 '22 02:11

Justin Leitgeb