嘗試添加simplecov到我的Rails應用程序(Jruby 1.6.4,Ruby 1.9.2,Windows)。我說「simplecov」到Gemfile中,捆綁安裝,下面我spec_helper的頂部:安裝simplecov後JRuby rspec異常
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
不認爲你需要require'rubygems';我知道我的spec_helper.rb沒有它。我使用spork雖然所以我的第一行是要求'spork' – 2011-12-29 22:14:01