我无法为我的Ruby on Rails应用程序运行单元测试。我在Windows7 x64和32x上使用的是JRuby 1.6.4 --这两种环境都遇到了同样的问题。
当我发出"rake test“命令时,输出如下:
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method TrainerWeb::Application#task called at C:/Program Files/jruby-1.6.4/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:214:in `initialize_tasks'
DEPRECATION WARNING: Rake tasks in D:/Work/P/Documents/NetBeansProjects/myproject/vendor/plugins/restful-authentication/tasks/auth.rake are deprecated. Use lib/tasks instead. (called from (root) at D:/Work/P/Documents/NetBeansProjects/myproject/Rakefile:13)
LoadError: no such file to load -- rake
require at org/jruby/RubyKernel.java:1038
(root) at C:/Program Files/jruby-1.6.4/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:1
LoadError: no such file to load -- rake
require at org/jruby/RubyKernel.java:1038
(root) at C:/Program Files/jruby-1.6.4/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:1
LoadError: no such file to load -- rake
require at org/jruby/RubyKernel.java:1038
(root) at C:/Program Files/jruby-1.6.4/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:1
Errors running test:units, test:functionals, test:integration!对于irb,"require 'rake'“命令会给出以下输出:
irb(main):001:0> require 'rake'
LoadError: no such file to load -- rake
from org/jruby/RubyKernel.java:1038:in `require'
from (irb):1:in `evaluate'
from org/jruby/RubyKernel.java:1088:in `eval'
from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1191:in `catch'
from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1191:in `catch'
from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:70:in `start'
from C:\Program Files\jruby-1.6.4\bin\irb:13:in `(root)'我尝试在NetBeans中运行测试时会产生另一个输出:
Test-unit version : 2.4.5 loaded
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method TrainerWeb::Application#task called at C:/Program Files/jruby-1.6.4/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:214:in `initialize_tasks'
DEPRECATION WARNING: Rake tasks in D:/Work/P/Documents/NetBeansProjects/myproject/vendor/plugins/restful-authentication/tasks/auth.rake are deprecated. Use lib/tasks instead. (called from (root) at D:/Work/P/Documents/NetBeansProjects/myproject/Rakefile:13)
'"C:/Program Files/jruby-1.6.4/bin/jruby.bat.exe"' is not recognized as an internal or external command,
operable program or batch file.
'"C:/Program Files/jruby-1.6.4/bin/jruby.bat.exe"' is not recognized as an internal or external command,
operable program or batch file.
'"C:/Program Files/jruby-1.6.4/bin/jruby.bat.exe"' is not recognized as an internal or external command,
operable program or batch file.
Errors running test:units, test:functionals, test:integration!
Finished in 0.0 seconds.
0 tests, 0 failures, 0 errorsGemfile引用了rake。
我在互联网上找不到像样的解决方案。
发布于 2012-03-21 20:50:24
卸载JRuby并将其重新安装到C:\jruby-1.6.4后,一切正常。所以问题是路径中的一个空格符号。
发布于 2012-03-16 05:43:00
不知道这有没有帮助,但我也有同样的问题。我的解决方案是添加以下环境变量: RUBYOPT='-rrubygems‘这导致每次自动加载rubygems,我的问题就消失了……
https://stackoverflow.com/questions/9008731
复制相似问题