Ruby on rails 我的rails测试产生了乱七八糟的输出
我刚刚赶上了一个新项目,Ruby on rails 我的rails测试产生了乱七八糟的输出,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我刚刚赶上了一个新项目,rake测试产生了大量乱七八糟的输出。为什么会这样?我尝试移除所有我不知道的宝石,但我的输出仍然是模糊的。我通过bundle exec rake test调用测试套件 示例输出-这是此类内容的页面 /Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warni
rake测试产生了大量乱七八糟的输出。为什么会这样?我尝试移除所有我不知道的宝石,但我的输出仍然是模糊的。我通过bundle exec rake test
调用测试套件
示例输出-这是此类内容的页面
/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead
/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead
/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead
/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead
.ruby version
文件中的ruby版本是2.2.2
。安装的rails版本为3.2.22.5
我的测试宝石是:
group :test, :development do
# gem 'rack-mini-profiler'
# gem 'minitest'
gem 'minitest-rails'
gem 'test-unit'
gem 'shoulda'
gem 'shoulda-matchers'
gem 'fabrication'
gem 'byebug'
end
然后我再次检查了我的Rakefile
。它有以下内容:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
WooWoop::Application.load_tasks
task default: [:test]
我唯一能想到的是我的测试助手
。我把内容贴在下面。看起来不错
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "minitest/pride"
require 'shoulda'
require 'shoulda/matchers'
# $VERBOSE=nil
# ActiveRecord::Migration.check_pending!
ActiveSupport::TestCase.test_order = :random
# Protractor test or even some dirty debugging in the rails console on test environment
# might have left some garbage on the DB. Lets make sure we start with a clean state.
# parses the response and returns it.
唯一可以使输出静音的方法是使用RUBYOPT=W0 TEST=TEST/unit/shop\u TEST.rb be rake TEST
。这是我使用rails 3的唯一方法吗
更新:
我现在尝试降级到ruby 2.0.0
我仍然收到很多以前从未见过的奇怪警告
/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:89: warning: instance variable @mount_on not in
itialized
/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:243: warning: instance variable @previous_model_for_showcase_cov
er_picture not initialized
/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:89: warning: instance variable @mount_on not in
itialized
/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:243: warning: instance variable @previous_model_for_manager_pict
ure not initialized
(eval):11: warning: instance variable @opening_hours_monday_from not initialized
(eval):2: warning: instance variable @opening_hours_monday_to not initialized
(eval):11: warning: instance variable @opening_hours_tuesday_from not initialized
(eval):2: warning: instance variable @opening_hours_tuesday_to not initialized
(eval):11: warning: instance variable @opening_hours_wednesday_from not initialized
(eval):2: warning: instance variable @opening_hours_wednesday_to not initialized
(eval):11: warning: instance variable @opening_hours_thursday_from not initialized
(eval):2: warning: instance variable @opening_hours_thursday_to not initialized
(eval):11: warning: instance variable @opening_hours_friday_from not initialized
(eval):2: warning: instance variable @opening_hours_friday_to not initialized
(eval):11: warning: instance variable @opening_hours_saturday_from not initialized
(eval):2: warning: instance variable @opening_hours_saturday_to not initialized
编辑:
我最终升级到rails 4。所有警告都已消失。消除警告的三个(其他)选项:
降级Ruby直到警告消失。您使用的是Ruby 2.2之前创建的旧版本RailsFile.exists?
在Ruby 2.2之前的某个时候被弃用
在gem存储库中手动编辑有问题的行
在gem存储库中运行“大规模搜索并替换shell”命令:
…当然还有最后一个选择:升级Rails。我降级到Ruby 2。现在我也收到了很多其他的警告。我怀疑我的测试有点疯狂<代码>(评估):11:警告:实例变量@opening\u hours\u monday\u from not initialized
例如。@Hendrik Ouch..听起来很复杂:-/您可以尝试将其作为RUBYOPT=“-W0”rake test运行。见他问题的最后一行。关闭警告和降级软件是最后的手段。我希望升级是可能的。您将面临巨大的风险。项目以前使用过哪个Ruby版本?为什么不使用与原始项目中相同的版本?不要给自己制造太多的麻烦。那是2.0.0-p481
。我来试一试。我现在还记得升级的原因:警告:ruby-2.0.0-p481已经过时,现在不受支持。它不再接收错误修复或关键安全更新。