【发布时间】:2012-07-18 02:05:58
【问题描述】:
尝试将 simplecov 添加到我的 Rails 应用程序(Jruby 1.6.4、Ruby 1.9.2、Windows)。我将“simplecov”添加到 Gemfile、捆绑安装,并将以下内容添加到我的 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
【问题讨论】:
-
不要认为你需要 require 'rubygems' ;我知道我的 spec_helper.rb 没有它。我用的是 spork,所以我的第一行是 require 'spork'
标签: ruby-on-rails rspec jruby code-coverage