测试单元与 ruby 2.2.0 不兼容吗?

Is test-unit incompatible with ruby 2.2.0?

我真的是 ruby 的新手。我开始按照 this 设置 ruby 指南进行游戏,rvm,将我所有的 mac 更新到当前版本,没有任何问题。所以我安装了 test-unit gem 并尝试了一些 TDD 脚本。 运行 测试没有任何反应。所以我 运行 ruby 使用“-d”选项,这就发生了。

Exception 'LoadError' at /Users/BlackSheep/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems.rb:1222 - cannot load such file -- rubygems/defaults/operating_system

Exception 'LoadError' at /Users/BlackSheep/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems.rb:1231 - cannot load such file -- rubygems/defaults/ruby

Exception `LoadError' at /Users/BlackSheep/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54 - cannot load such file -- test/unit

Exception 'NoMethodError' at /Users/BlackSheep/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1984 - undefined method `to_ary' for #

Exception 'NoMethodError' at /Users/BlackSheep/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1984 - undefined method 'to_ary' for #

可能是什么问题?

版本:

编辑:我已经降级到 2.0.0 版并且工作正常。所以测试单元 gem 不是为当前 ruby 版本制作的?

直到 2.1,Ruby 随 test/unit 一起提供,但从 2.2 开始,它已被删除。

它仍然可用 gem:https://github.com/test-unit/test-unit/。来自自述文件:"Test::Unit 1.2.3 is the original Test::Unit, taken straight from the ruby distribution. It is being distributed as a gem to allow tool builders to use it as a stand-alone package. (The test framework in ruby is going to radically change very soon)."

如果您确定测试单元 gem 已安装(gem install test-unit 或将 gem 'test-unit' 添加到您的 Gemfile)它应该可以解决问题。