我正在尝试升级Rails 2.3.9应用程序以使用Ruby 1.9.2-p290;以前该应用程序使用Ruby 1.8.7。我注意到一些怪癖,最值得注意的是我不能在我的应用程序中运行任何测试 - 不是单独测试而不是rake测试。
minitest在运行任何测试之前抛出错误:
undefined method `name' for ActionView::TestCase.
完整的堆栈跟踪如下。
$ bundle exec rake test:units
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
/Users/me/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -I"lib:test" -I"/Users/me/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib" "/Users/me/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb"
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/rails-2.3.9/lib/rails/gem_dependency.rb:21.
NOTE: Gem::SourceIndex#refresh! is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#refresh! called from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/rails-2.3.9/lib/rails/vendor_gem_source_index.rb:34.
NOTE: Gem::SourceIndex#load_gems_in is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#load_gems_in called from /Users/me/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:322.
Run options: --seed 48289
# Running tests:
EEEE/Users/me/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-2.3.9/lib/action_controller/test_process.rb:511:in `method_missing': undefined method `name' for #<ActionView::TestCase:0x007fa0ee39ece8> (NoMethodError)
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-2.3.9/lib/action_view/test_case.rb:158:in `method_missing'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-2.3.9/lib/active_support/testing/setup_and_teardown.rb:26:in `rescue in run'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-2.3.9/lib/active_support/testing/setup_and_teardown.rb:33:in `run'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:812:in `block in _run_suite'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:805:in `map'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:805:in `_run_suite'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:795:in `block in _run_suites'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:795:in `map'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:795:in `_run_suites'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:771:in `_run_anything'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:934:in `run_tests'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:921:in `block in _run'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:920:in `each'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:920:in `_run'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:909:in `run'
from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.7.0/lib/minitest/unit.rb:689:in `block in autorun'
Run options: --seed 52971
# Running tests:
答案 0 :(得分:0)
事实证明我的宝石环境很糟糕:我使用的是ruby 1.8.7,但我的GEM路径指向ruby 1.9.2。