仍然在Rails3.1中获得弃用警告

时间:2011-09-28 07:37:37

标签: testing ruby-on-rails-3.1

我在Rails 3.1中测试时一直收到折旧警告,如

    RailsProject$ bundle exec autotest
    NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
    Gem.source_index called from /Users/CS/.rvm/gems/ruby-1.9.2-p290/gems/ZenTest-4.5.0/lib/autotest.rb:226.
    NOTE: Gem::SourceIndex#gems is deprecated with no replacement. It will be removed on or after 2011-11-01.
    Gem::SourceIndex#gems called from /Users/CS/.rvm/gems/ruby-1.9.2-p290/gems/ZenTest-4.5.0/lib/autotest.rb:226.
    loading autotest/rails
    /Users/CS/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -I.:lib:test -rubygems -e "%w[test/unit test/unit/rim_test.rb test/unit/page_test.rb test/functional/pages_controller_test.rb test/unit/helpers/pages_helper_test.rb test/unit/order_test.rb test/unit/admin_user_test.rb test/unit/helpers/cart_helper_test.rb test/unit/customer_test.rb test/unit/ordered_service_test.rb test/unit/services_test.rb test/functional/cart_controller_test.rb].each { |f| require f }" | unit_diff -u
    /Users/CS/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/rubygems_ext.rb:43: warning: method redefined; discarding old gem_dir
    /Users/CS/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1262: warning: previous definition of gem_dir was here
    /Users/CS/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/rubygems_ext.rb:154: warning: method redefined; discarding old hash
    /Users/CS/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb:125: warning: previous definition of hash was here
    /Users/CS/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/rubygems_integration.rb:183: warning: method redefined; discarding old initialize
    /Users/CS/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb:53: warning: previous definition of initialize was here

我的版本:

    RailsProject$ bundle exec rails -v
    Rails 3.1.0
    RailsProject$ bundle exec gem -v
    1.8.10
    RailsProject$ bundle exec bundle -v
    Bundler version 1.0.18

我尝试了所有gem pristine --all --no-extensions来自this post的内容 - 有无bundle exec

每个宝石都是最新的。

有人知道如何解决这个问题吗?

2 个答案:

答案 0 :(得分:1)

问题是您没有使用最新版本的ZenTest。您使用的是4.5.0,最新的是4.6.2。

尝试运行

gem update ZenTest
gem update autotest

您可能需要更新rails应用中的 Gemfile 并运行bundle install以将gemfile锁定到最新版本的gem。

答案 1 :(得分:0)

您需要安装ZenTest 4.6.2。 如果你使用rails 3.1,你会发现 autotest-rails(4.1.1)依赖于ZenTest(= 4.5.0)。 刚刚修改了Gemfile.lock,搜索ZenTest,将其更改为使用4.6.2,然后更改

autotest (4.4.6)
  ZenTest (= 4.5.0)

autotest (4.4.6)
  ZenTest (= 4.6.2)

然后,运行

bundle install

就是这样。