0

我最近设置了 Zeus 和 Minitest 来测试 Rails 应用程序。

但是,我收到以下错误:

leo% zeus test
/Users/leo/.rvm/gems/ruby-1.9.3-p125@backscratchers/gems/turn-0.9.6/lib/turn/minitest.rb:23:in `<top (required)>': MiniTest v5.0.8 is out of date.
`gem install minitest` and add `gem 'minitest' to you test helper. (RuntimeError)
  from /Users/leo/.rvm/gems/ruby-1.9.3-p125@backscratchers/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
  from /Users/leo/.rvm/gems/ruby-1.9.3-p125@backscratchers/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
  ... etc ...

Turn gem 中提到的行是:

# set MiniTest's runner to Turn::MiniRunner instance
if MiniTest::Unit.respond_to?(:runner=)
  MiniTest::Unit.runner = Turn::MiniRunner.new
else
  raise "MiniTest v#{MiniTest::Unit::VERSION} is out of date.\n" \
        "`gem install minitest` and add `gem 'minitest' to you test helper."
  #MiniTest::Unit = Turn::MiniRunner
end

所以“过时”可能有点误导。它真正的意思是 API 不是预期的,对吧?

gem 'turn'从我的 Gemfile 中删除,运行bundle install并重新启动 Zeus。

现在我得到:

/Users/leo/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:328:in `autorun': uninitialized class variable @@installed_at_exit in Test::Unit::Runner (NameError)
  from /Users/leo/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:640:in `<top (required)>'
  from /Users/leo/.rvm/gems/ruby-1.9.3-p125@backscratchers/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
  from /Users/leo/.rvm/gems/ruby-1.9.3-p125@backscratchers/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
  from /Users/leo/.rvm/gems/ruby-1.9.3-p125@backscratchers/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `l
... etc ...

这里发生了什么?我是否有错误的 Minitest 版本?为什么 Bundler 无法弄清楚依赖链,我认为这就是重点。

任何建议都非常感谢。

4

1 回答 1

2

那么直接的解决方案似乎是降级 Minitest:

gem 'minitest', '~> 4'

但是,这似乎会在运行特定测试时导致连锁问题,因为我现在uninitialized constant MiniTest::Test在实际运行测试时遇到错误。

更新:

似乎旧版本的 MiniTest 使用了不同的模块/类层次结构,因此Minitest::Test必须成为MiniTest::Unit::TestCase.

注意 Minitest > MiniTest 的大小写。

要查看 MiniTest/Minitest 可以使用哪些类,您可以使用:

MiniTest.constants.select {|c| Class === MiniTest.const_get(c)}
于 2013-10-30T10:22:22.980 回答