0

我最近开始在我的 Rails 2.3 webapp 中使用 JRuby。从那以后,我的 rspec 测试一直很慢……自从我切换到 JRuby 后,测试运行时间太长了。

在使用 MRI 时,我从不费心使用 spork 来更快地运行测试,但现在我需要加快测试的执行速度。

首先,我尝试了 spork,但没有成功,因为:

  1. spork 0.9 RC支持jruby,但不支持rails 2.3 (它只支持rails 3
  2. spork 0.8支持rails 2.3,但不支持jruby我认为它使用 fork(),spork-0.8 gem不会在jruby上安装事件)。

我试图在jrubyrails 2.3spork 0.9 rc上运行我的测试,但没有成功,实际上有一条警告消息说spork 0.9 rc只支持rails >= 3.0

然后我尝试了 nailgun,我在我的 jruby 环境中安装了 nailgun gem(gem install nailgun)并启动了 nailgun 服务器(ruby​​ --ng-server在我的应用程序的根目录)。然后我运行我的一个规范(ruby​​ --ng -S spec spec/lib/importacao_atividades_spec.rb)。我第一次执行规范时,它运行得很好,但之后它不断提高RuntimeError: invalid runtime

检查跟踪:

RuntimeError: invalid runtime
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/activesupport-2.3.10/lib/active_support/dependencies.rb:184
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/mysql-2.8.1/lib/mysql.rb:3
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/mysql-2.8.1/lib/mysql.rb:68
          each at org/jruby/RubyArray.java:1602
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66
          each at org/jruby/RubyArray.java:1602
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler.rb:120
     load_gems at /Users/razenha/Projects/Pro/portaltrademarketing/config/boot.rb:116
       process at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rails-2.3.10/lib/initializer.rb:164
          send at org/jruby/RubyKernel.java:2052
           run at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rails-2.3.10/lib/initializer.rb:113
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/config/environment.rb:12
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/config/environment.rb:47
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/spec/spec_helper.rb:1
          load at org/jruby/RubyKernel.java:1063
    load_files at ./spec/lib/importacao_atividades_spec.rb:15
          each at org/jruby/RubyArray.java:1602
    load_files at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:14
  run_examples at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/options.rb:132
           run at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/bin/spec:5
          load at org/jruby/RubyKernel.java:1063
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/bin/spec:19

所以我真的被困在这里。有人知道我该如何解决钉枪问题吗?如果没有,是否有替代方案?是否可以在 jruby 和 rails 2.3 中使用 spork?

4

1 回答 1

0

哦...看起来 jruby 不喜欢旧版本的 Redis gem。更新了我的 Resque/Redis gem 版本并且它有效。

于 2011-05-17T20:59:09.600 回答