尝试将simplecov添加到我的Rails应用程序(Jruby 1.6.4,Ruby 1.9.2,Windows)。我将'simplecov'添加到Gemfile,bundle install,以及以下内容到我的spec_helper顶部:
require 'rubygems'
require 'simplecov'
SimpleCov.start 'rails'
运行时,我得到以下异常:
$ bundle exec rspec --debug spec
No DRb server is running. Running in local process instead ...
c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/ruby-debug-base.rb:214 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-0.5.4/lib/simplecov.rb:33 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
LoadError: load error: rails/railtie -- java.lang.NegativeArraySizeException: null
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/engine.rb:1
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/engine.rb:1
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/plugin.rb:4
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/application.rb:10
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails.rb:1
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/actionpack-3.1.0/lib/action_controller/railtie.rb:5
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/railsProjects/txprepaid/config/application.rb:2
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/railsProjects/txprepaid/config/environment.rb:13
require at org/jruby/RubyKernel.java:1047
(root) at c:/dev/railsProjects/txprepaid/spec/spec_helper.rb:1
load at org/jruby/RubyKernel.java:1073
load_spec_files at c:/dev/railsProjects/txprepaid/spec/controllers/dictionary_controller_spec.rb:459
collect at org/jruby/RubyArray.java:2344
load_spec_files at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459
run at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18
run_in_process at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80
run at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:66
autorun at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10
ArgumentError: same file: c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-html-0.5.3/lib/../assets/app.js and C:/dev/railsProjects/txprepaid/coverage/assets/0.5.3/app.js
fu_each_src_dest at c:/dev/apps/jruby-1.6.4/lib/ruby/1.9/fileutils.rb:1417
fu_each_src_dest0 at c:/dev/apps/jruby-1.6.4/lib/ruby/1.9/fileutils.rb:1432
fu_each_src_dest at c:/dev/apps/jruby-1.6.4/lib/ruby/1.9/fileutils.rb:1416
cp_r at c:/dev/apps/jruby-1.6.4/lib/ruby/1.9/fileutils.rb:432
format at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:15
each at org/jruby/RubyArray.java:1603
format at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:14
format! at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-0.5.4/lib/simplecov/result.rb:90
at_exit at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-0.5.4/lib/simplecov/configuration.rb:133
call at org/jruby/RubyProc.java:262
(root) at c:/dev/apps/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-0.5.4/lib/simplecov/defaults.rb:47
答案 0 :(得分:2)
看起来并不是所有对JRuby的覆盖支持的支持都可以在下面的链接中看到,这可能会影响simplecov,因为它依赖于Ruby 1.9中预期的内置覆盖功能。
https://github.com/colszowka/simplecov/issues/86
答案 1 :(得分:0)
您可以尝试在1.9模式下使用jruby。你可以通过-1.9,但我通常会把
JRUBY_OPTS="--1.9"
在我的.bashrc中。不知道如何在Windows中设置env变量。