2016-11-09 21 views
1

我剛剛超過了一個新項目,並且rake test產生了很多亂碼輸出。爲什麼會這樣?我試着去除了所有我不知道的寶石,但我的輸出仍然是陰雲密佈。我通過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 

screenshot of the tests running

.ruby-version文件紅寶石版本是2.2.2。安裝的導軌版本是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] 

我唯一能想象的其他事情就是我的test_helper。我粘貼下面的內容。看上去不錯。

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_test.rb be rake test。這是自從我使用rails 3以來唯一的方法嗎?

更新:

我現在想降級到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 

編輯:

我最終結束了升級到軌4.所有的警告都沒有了。

+0

之前的項目使用哪個Ruby版本?你爲什麼不使用與原始項目相同的版本?不要爲自己創造比你需要創造更多的麻煩。 – Casper

+0

這是'2.0.0-p481'。我會給你一個鏡頭。 – Hendrik

+0

我記得現在爲什麼我升級了:'警告:ruby-2.0.0-p481已經過了它的使用壽命,現在不受支持。 它不再收到錯誤修復或重要的安全更新。「 – Hendrik

回答

1

三(其他)選項擺脫警告:

  1. 降級紅寶石,直到警告消失。您正在使用在Ruby 2.2之前創建的舊版Rails。 File.exists?在Ruby 2.2之前已被棄用。

  2. 手動編輯您的寶石庫中的違規行。

  3. 運行質量的搜索和你的寶石庫替換shell命令:
    https://superuser.com/questions/428493/how-can-i-do-a-recursive-find-and-replace-from-the-command-line

...當然還有最後一個選項:提升的Rails。

+0

我降級爲Ruby 2.現在我也收到了很多其他警告。我懷疑我有些事情會在我的測試中發生一些瘋狂。例如'(eval):11:warning:實例變量@opening_hours_monday_from未初始化「。 – Hendrik

+0

@ Hendrik Ouch ..聲音複雜: -/ – Casper

+2

你可以嘗試運行它爲'RUBYOPT =「 - W0」rake test' – max