Error while trying to make my rspec 1.2 tests go faster on JRuby and Rails 2.3.10 using nailgun and spork
I recently start using JRuby in my Rails 2.3 webapp. Since then, I have been experiencing slowness in my rspec tests... the test are taking too long to run since I switched to JRuby.
While using MRI, I never bothered to use spork in order to run my tests faster, but now I need to speed up the execution of my test.
First, I tried spork, but I did't worked out because:
- spork 0.9 RC supports jruby, but does not support rails 2.3 (it only supports rails 3)
- spork 0.8 supports rails 2.3, but does not support jruby I think it uses fork(), the spork-0.8 gem won't event install on jruby).
I tried to run my tests on jruby, rails 2.3 and spork 0.9 rc, but it didn't worked, in fact there was a warning message saying that spork 0.9 rc only supports rails >= 3.0
Then I tried nailgun, I installed the nailgun gem in my jruby environment (gem install nailgun) and started the nailgun server (ruby --ng-server at the root of my app). Then I run one of my specs (ruby --ng -S spec spec/lib/importacao_atividades_spec.rb). The first time I executed the spec, it went just fine, but after that it kept raising RuntimeError: invalid runtime
Check the trace:
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/R开发者_JS百科ubyKernel.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
So I am really stuck here. Anyone know how can I fix the nailgun issue? If not, is there an alternative? Is it possible to use spork in jruby and rails 2.3?
Oh... Looks like jruby does not like an older version of the Redis gem. Updated my Resque/Redis gem version and it worked.
精彩评论