如何在测试助手中添加gem'minitest'?

时间:2011-10-15 17:36:37

标签: ruby-on-rails tdd minitest

我是Ruby on Rails和测试的新手。当我运行rake test时,我收到以下错误:

/Users/jarvis/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rack-1.3.4/lib/rack/backports
/uri/common_192.rb:53: warning: already initialized constant WFKV_
/Users/jarvis/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/turn-0.8.3/lib/turn/autorun
/minitest.rb:14:in `<top (required)>': MiniTest v1.6.0 is out of date. (RuntimeError)
`gem install minitest` and add `gem 'minitest' to you test helper.
    from /Users/jarvis/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.1.1/lib
/active_support/dependencies.rb:240:in `require'

我做了gem install minitest现在它说将gem'minitest'添加到我的测试助手中。这是test/test_helper.rb,如果是,我如何“添加”minitest?

2 个答案:

答案 0 :(得分:26)

编辑Gemfile,以便在测试组下指定gem,如下所示:

group :test do
  gem "minitest"
end

(发布OP编辑到问题中的解决方案,但没有作为答案发布)

答案 1 :(得分:3)

首先卸载你的minitest。 gem uninstall minitest。

如果您使用转弯,请确保版本低于0.8.3

将这些代码放在Gemfile的底部

group :test do
  gem 'turn', '< 0.8.3'
  gem 'minitest'
end

然后运行

bundle install