试图在rails源代码中运行“rake test”

时间:2012-02-04 08:39:52

标签: ruby-on-rails-3

我刚刚从github克隆了rails源代码,并试图运行测试套件......我遇到了重大失败:

patrick@vincent:~/coding/rails/rails(master)>bundle exec rake test --trace
** Invoke test (first_time)
** Execute test
/Users/patrick/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -w -I"lib:test" -I"/Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib" "/Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" 
/Users/patrick/coding/rails/rails/activesupport/lib/active_support/test_case.rb:20:in `<class:TestCase>': undefined method `register_spec_type' for ActiveSupport::TestCase:Class (NoMethodError)
    from /Users/patrick/coding/rails/rails/activesupport/lib/active_support/test_case.rb:11:in `<module:ActiveSupport>'
    from /Users/patrick/coding/rails/rails/activesupport/lib/active_support/test_case.rb:10:in `<top (required)>'
    from /Users/patrick/coding/rails/rails/activesupport/test/benchmarkable_test.rb:3:in `<top (required)>'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `require'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180@rails_patch/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [/Users/patrick/.rvm/rubies/ruby-1.9.2-p180...]

Tasks: TOP => test
(See full trace by running task with --trace)

之后有更多类似的错误输出,看起来相当相同,所以我不打算在这里粘贴它...

有谁知道如何让这些测试运行?

1 个答案:

答案 0 :(得分:9)

你在ruby 1.9.2下运行。 rails master分支(又名Rails 4)需要ruby 1.9.3或更高版本。缺少的方法register_spec_type将由ruby 1.9.3解决。

我看到你正在使用RVM,这很棒。这将使升级到1.9.3变得容易......

根据您的RVM副本的年龄,您可能需要使用以下命令升级它:

$ rvm get stable

然后,确保安装了ruby 1.9.3并且您正在使用它:

$ rvm install 1.9.3
$ rvm use 1.9.3

您可能需要重新安装捆绑包中的所有宝石:

$ bundle install

现在您应该可以使用以下命令成功运行测试:

$ bundle exec rake test