我刚刚更新了我的所有宝石,我发现我试图运行Test :: Unit测试时会收到错误.我收到下面的错误.这来自于创建新的,空的Rails项目,脚手架一个简单的模型,并运行rake测试.
试图搜索“未初始化常数”和TestResultFailureSupport.我发现唯一的事情是2007年this bug report.
我正在使用OS X.
这些是在测试停止工作之前更新的宝石:
$sudo gem outdated Password: RedCloth (4.2.1 < 4.2.2) RubyInline (3.8.1 < 3.8.2) ZenTest (4.1.1 < 4.1.3) bluecloth (2.0.4 < 2.0.5) capistrano (2.5.5 < 2.5.8) haml (2.0.9 < 2.2.1) hoe (2.2.0 < 2.3.2) json (1.1.6 < 1.1.7) mocha (0.9.5 < 0.9.7) rest-client (1.0.2 < 1.0.3) thoughtbot-factory_girl (1.2.1 < 1.2.2) thoughtbot-shoulda (2.10.1 < 2.10.2)
有没有人看到这个问题?任何故障排除建议?
UPDATE
在预感中,我将ZenTest从4.1.3降级到4.1.1,现在一切都重新起作用.
仍然好奇地知道有没有人看过这个或有任何有趣的意见或见解.
$rake test (in /Users/me/foo) /usr/local/bin/ruby -I"lib:test" "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/helpers/users_helper_test.rb" "test/unit/user_test.rb" /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError) from /usr/local/lib/ruby/gems/1.8/gems/test-unit-2.0.2/lib/test/unit/testresult.rb:28 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /usr/local/lib/ruby/gems/1.8/gems/test-unit-2.0.2/lib/test/unit/ui/testrunnermediator.rb:9 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' ... 6 levels... from /usr/local/lib/ruby/1.8/test/unit/autorunner.rb:214:in `run' from /usr/local/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' from /usr/local/lib/ruby/1.8/test/unit.rb:278 from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5 /usr/local/bin/ruby -I"lib:test" "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/functional/users_controller_test.rb"
解决方法
如果模块在嵌套在其中的父模块尚未加载时在单个语句中声明,则可能会发生这种情况.我没有看过这些宝石的代码,但是我的预感是这是正在发生的事情.查克的解决方案会表明.首先调用gem’test-unit’将加载父模块,所以禅宗测试的设置结束了.
例如
module Foo::Bar def do_stuff # insert awesomeness here... end end
如果父Foo模块尚未定义(例如由另一个gem),将导致错误
一个更安全的方式来宣布这一点
module Foo module Bar def do_stuff # insert awesomeness here... end end end
可能是Zentest中需要修补的错误.